I’m working on an application where users can upload files to OpenAI’s storage. After uploading, the files should be automatically assigned to the vector store for an assistant I’ve created. While the upload process works fine, I’m encountering an issue when trying to assign the files to the vector store.
Below is a screenshot showing that the files were uploaded successfully, followed by a screenshot where the assignment to the vector store failed.
I raised the upload issue with OpenAI last week, the issue is this is mostly done by a Microsoft service called AI search, and it seems it’s that part that is having issues. I will raise it again.
I am getting this issue too, but can’t tell if it’s an issue with my formatting. I am uploading JSON file. It uploads just fine through API but we get a 400 error when trying to attach the files to a vector store.
That’s interesting. Because while debugging, in my code I get response 200. But it shows status ‘Failed’ on website under my account.
I used create vector store file api for attaching file I uploaded to vector store of an assistant.
Below is the code chunk I wrote,
# Assign uploaded files to the assistant's vector store
def assign_file_to_vector_store(file_id):
vector_store_url = f"https://api.openai.com/v1/vector_stores/{VECTOR_STORE_ID}/files"
assistant_upload_headers = {
"Authorization": f"Bearer {OPENAI_API_KEY}",
"Content-Type": "application/json",
"OpenAI-Beta": "assistants=v2"
}
data = {
"file_id": file_id
}
response = requests.post(vector_store_url, headers=assistant_upload_headers, json=data)
if response.status_code == 200:
return response.json()
else:
raise Exception(f"Error assigning file to vector store: {response.text}")
Have you found a solution to this? I am running into the exact same issue. I will look into turning the pdf into json. My pdfs are images of text, somtimes they work, sometimes they dont, but there seems to be consistency with files.
If the file failed once, it will always fail, but if it works once, it will always work.
I’ve been researching related topics on the OpenAI community and other resources but haven’t found a definitive solution yet. However, I did discover a workaround that’s been working for me temporarily.
While debugging, I noticed that when uploading multiple files at once, they fail to be assigned to the vector store. To address this, I modified my approach to upload files one by one, with a time delay between each upload. After doing this, the files are successfully assigned to the assistant’s vector store.
This isn’t a long-term fix, so I’m hoping to find a more permanent solution soon.