In Assistant API, I’m adding a txt file as an attachment to the thread, small file or large file doesn’t seem to matter .
I upload the file, and get a FileId, I can see the file in openAI storage
I add the fileid to the thread.
I create a run
I get the run response
And randomly get this in the response, it works maybe 70% of the time, even with identical files and process
"last_error": {
"code": "server_error",
"message": "Sorry, something went wrong."
},
If I retry the exact same process, 90% of the time it will work on a 2nd rerun.
So its leading me to have to write horrible retry code, and loops to check for this failure to try and work around the issue.
My request is, for better error messages if indeed something is being done incorrectly, I kinda suspect its something to do with the Vector Store maybe not being ready, or taking a lot time to update on occasion, have tried putting thread delays into my code to see, but its hard to really understand what the issue is.
I know its been reported before and the response from openai seems to be something to do with uploaded files, but there is no information to say just exactly what that is.
Yes, it would be nice if the server can always respond with a more detailed error, but if the fault prevents the server from responding then you get the generic Internal Server Error or equivalent.
An intermittent server error usually indicates a timeout occurring. So, you can try to eliminate the vector store as being the problem by using the vector stores endpoint vector stores files service to check that all the files there have status completed before starting your run.
Ive been looking at the Vector Store, im pretty sure now thats the issue.
When you upload a file it creates a temporary Vector Store, I think its this temporary Vector store that sometimes takes too long to index.
I was polling on the File upload till it got status “processed”, but it doesn’t look like that takes into account the Vector store being indexed.
My solution, which seems to be working now, fingers crossed is to upload the file first, then create my own vector store and add that file to it, then poll the new vector store till its status = “completed”
Then continue on and add the file id to the thread.
Can you recover right after the failure to see if the vector store status is still completed. Want to make sure the vector store did not expire while your thread is running.
The other thing to try is to create a vector store beforehand, either programmatic or by using your dashboard. Then have your program use the id of that vector store to add files to it. Then check the status of the vector store before the run. The idea is to make sure the vector store is ready to receive files. Does that make sense?
I found out that even though I created a new vector store, and waited for it to process, the assistant thread creates its own vector store if you add a message to a thread by file id, so the file ends up being shared between 2 vector stores,
In the docs I see I could add the vector store I created to the Thread by vector store id , so I’m doing this rather than adding the file to the message by file id.