How are you managing threads for long term use?

Hi there
How is everybody managing threads for long term use. What I want to do is have a user session and store those threads. Then when the user comes back another time have access to the previous messages. I’m thinking of doing this a few ways. Your feedback is appreciated

Method 1:

  1. use in build thread retrieval such that I can query the assistant id and latest thread id but also need to add in a user id somehow since I will have many users accessing it. So every time a new session opens it does this retrieval via OpenAI api and displays the last 5 messages. I would store only the user id, thread id and assistant id in a db

Questions on this method:

  • how long does open ai manage threads before they get deleted?
  • sound costly?
  • what database would you recommend? Mongo or Postgress?

method 2

Store the entire thread, assistant id and user id etc in my own database. Retrieve the last 5 messages and pass that on as context to the assistant

Questions.

  • is this overkill?
  • is there a db to recommend here?

Method 3

  1. store the user id, assistant id and thread id and only store a short summary of the previous session. Use that to retrieve as context for the chat

Questions

  • will this work well as in be clear enough for the assistant?
  • has anybody tried this?

Thank you in advance

3 Likes

https://platform.openai.com/docs/models/how-we-use-your-data

this might help answer some of your questions