openai.NotFoundError: Error code: 404 for file IDs in vector store

When I create a vector store, I’m receiving the error message
“openai.NotFoundError: Error code: 404 - {‘error’: {‘message’: ‘Files [list of my files] were not found’, ‘type’: ‘invalid_request_error’, ‘param’: None, ‘code’: None}}”
for the files I have listed for file_ids:

vector_store = client.beta.vector_stores.create(
    name="FSP prep docs",
    file_ids= ["/Users/me/Desktop/path to file","/Users/me/Desktop/path to file",...]
)

I followed the OpenAI documentation, but they don’t really specify how to do file paths. I know my files exist because I ran this code to see if the paths exist, and they do:

for path in file_paths:
    if os.path.exists(path):
        print(f"File exists: {path}")
    else:
        print(f"File NOT found: {path}")

What could I potentially be doing wrong? I’m trying to use these files as knowledge for my assistant.

1 Like

I think you’re not uploading your files to OpenAi.
Here’s what you need to do :

vector_store = client.beta.vector_stores.create( name="FSP prep docs")
file_paths = ["/Users/me/Desktop/path to file","/Users/me/Desktop/path to file",...]
file_streams = [open(path, "rb") for path in file_paths]
#this part is to upload it to openAi
file_batch = client.beta.vector_stores.file_batches.upload_and_poll(
  vector_store_id=vector_store.id, files=file_streams
)

Hope that helps, let me know

1 Like

[quote=“arely83, post:1, topic:870878”]
When I create a vector store, I’m receiving the error message
“openai.NotFoundError: Error code: 404 - {‘error’: {‘message’: ‘Files [list of my files] were not found’, ‘type’: ‘invalid_request_error’, ‘param’: None, ‘code’: None}}”
for the files I have listed for file_ids:


[/quote] Sure, here is the response in English:


Hello,

When I create a vector store, I receive the following error message:

openai.NotFoundError: Error code: 404 - {'error': {'message': 'Files [list of my files] were not found', 'type': 'invalid_request_error', 'param': None, 'code': None}}

For the files I have listed for file_ids.

To address this issue, I followed these steps:

  1. Verify File IDs (file_ids):

    • I ensured that the files specified are indeed present at the specified locations using code to check file paths.
  2. Review Documentation:

    • I reviewed the OpenAI documentation to ensure the format used for specifying file paths and file IDs is correct.
  3. Use Code to Check File Paths:

    • I used the following code to verify the existence of the files at the specified paths before attempting to create the vector store:
    import os
    
    file_paths = ["path/to/your/file1", "path/to/your/file2"]  # Replace with your actual file paths
    for path in file_paths:
        if os.path.exists(path):
            print(f"File exists: {path}")
        else:
            print(f"File not found: {path}")
    

After confirming that the files exist, the issue still persists. Are there any additional steps or recommendations to resolve this problem?

Thank you for your assistance.


I hope this helps. If you need any further adjustments or additional information, please let me know.

You must upload your files before creating the vector store. When you create your vector store you must use the file ID returned by the API.

           const openAiFile = await openai.files.create({
               file,
              purpose: "assistants"
          });

use the openAiFile.id after to create your vector store

Full code example: OpenAssistantGPT/app/api/chatbots/[chatbotId]/chat/route.ts at main · marcolivierbouch/OpenAssistantGPT · GitHub

I was have the same error and solve this following the steps:

  1. Create a Vector Store;
  2. Upload file;
  3. Create Vector Store File.