// Prepare the JSON payload
nlohmann::json request_body = {
{"model", "gpt-3.5-turbo"},
{"temperature", 0.7},
{"max_tokens", 256},
{"top_p", 1},
{"frequency_penalty", 0},
{"presence_penalty", 0},
{"messages", {
{{"role", "system"}, {"content", "You are a helpful assistant."}},
{{"role", "user"}, {"content", question}}
}}
};
// Include the conversation ID in the request body if it exists and is not older than 24 hours
if (!conversation_id.empty()) {
request_body["messages"].push_back({{"role", "system"}, {"content", "Previous conversation ID: " + conversation_id}});
}
// Setup the headers
std::multimap<std::string, std::string> headers = {
{"Authorization", "Bearer " + api_key},
{"Content-Type", "application/json"}
};```
#How do I do this properly so that the conversation is continued?
1 messages · Page 1 of 1 (latest)
Or is the ID in the API response pointless?
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "Onii-chan is a Japanese term that means \"older brother.\" It is often used by younger siblings or close friends to address or refer to an older brother or a male friend who is older than them. It is a term that conveys a sense of familiarity, affection, and respect.",
"role": "assistant"
}
}
],
"created": 1713139516,
"id": "chatcmpl-9E48ST52GHcXFR7zGc9RiRZlA5OHj",
"model": "gpt-3.5-turbo-0125",
"object": "chat.completion",
"system_fingerprint": "fp_c2295e73ad",
"usage": {
"completion_tokens": 58,
"prompt_tokens": 23,
"total_tokens": 81
}
}```
chat endpoint is stateless and that id is only for internal use cases or ban reporting