Reputation: 9428
When I use user
parameter on https://api.openai.com/v1/chat/completions, the memory is not persisted across multiple requests. How can we let the model memorize it across multiple requests?
Eg. is the message "My name is XXX" remembered by the ChatGPT API? Or do I have to send it every time? Then what is the purpose of the "user" variable if it is not used to remember things?
{
"model": "gpt-4",
"messages": [
{
"role": "user",
"content": "My name is XXX."
}
],
"user": "myuser"
}
Upvotes: 2
Views: 2427
Reputation: 1000
You have 2 options here. Use the Chat Completion API, that will be soon obsolete, or use the new Assistant API, the latter is exactly what you need. With the Chat Completion API you must add all the conversation texts every time you post a question, in that case ChatGPT will be able to extract from the previous question/answers the context and history of the conversation. With the new Assistant API (at the moment in beta version) that is done more efficiently and with less effort from your side because they have been developed to deal with what you need (test the assistant API playground on OpenAI website to check it). They released the assistant API a couple of weeks ago.
Upvotes: 2
Reputation: 391
Do you mean that previous messages are deleted? You'll have to remember them. The API doesn't do that. Make messages
a variable and append the response to it. Next time send the messages
variable which contains the previous response
Upvotes: 2