Send conversation history to the API (Conversation ID?)

Hey everyone,

I’m very new to using the ChatGPT API (with an Assistant). While coding (JavaScript), I noticed that there isn’t an option to send a Conversation ID with the prompt via a POST request. Some of you mentioned that sending the chat history with every request allows the API to understand the full context of the conversation.

Here’s my problem: I’ve stored my last two messages (I want to keep it limited since every request with more context means additional token costs) in a JSON file, and I’d like to attach this file to the POST request. Is it possible to attach the JSON as an “attachment” property, or do I have to include it directly in the “content” field of the prompt (which I would prefer not to do)?

(If there is another option, like a new Conversation ID, that would be great too. I just found Problems in this forum from over a year ago)

Best regards,
Johann

Store user and reply in a dbase along with user id/name. RAG

2 Likes

agree with this response. I’ve found a best practice is to maintain your own user/conversation DB so that anything your app/UI does, on top of the OpenAI APIs, is fully represented.

I’ve also found this helps defend against long term drift of APIs and code bases etc.

1 Like