Create a new Run on an existing Thread but use a different File Id each time

I am working on a chat to let users analyze their customers file, and I am using the new API to manage assistants, threads, messages and runs.

A file is attached to the Assistant through the API and users can then chat with the data contained in the file. Every morning, the latest customers file is uploaded automatically via the API and it replaces the old file with the Assistant.

Goal is for a user to create a thread, and then being able to schedule the automatic execution of this thread every day, but the new run would use the latest file that was uploaded and attached to the assistant.

I have tried the following without success:

  • create a new run on an existing thread hoping the new run would use the new file ID associated with the assistant. It doesn’t seem to work as the run is using the old file id.

  • update the thread with a new file id but the API doesn’t seem to allow it.

  • duplicate existing thread by creating a new thread and insert messages (both user and assistant) from the old thread. API doesn’t seem to allow the insertion of assistant messages into a thread.

Any thoughts on the best way to use the API to trigger a new run on an existing thread but using a different file ID each time?

The forced structure of threads is very strange (not allowing adding assistant messages… like what). So stupid considering the new token window is massive.

So maybe the solution is to summarize the current thread, destroy it, and then create a new thread with the summary + new file added to the user’s first message? Or even appending the instructions with the summary for the first message?

You could probably attach a timestamp in the metadata instead of having a timed event.

2 Likes