Couple of questions regarding file uploads, file search, and vector stores

I’m developing a Node.js application that calls the Assistants API. I would like to perform RAG by utilizing the FILE SEARCH and VECTOR STORE features.

  1. I intend for my app to have multiple users creating multiple agents. Should the vector store be at the user level or the agent level? I mean should a user’s agents all be able to access the same vector store, or should each vector store be particular to each agent?
  2. I’m currently uploading files using openai.files.create(), then creating a vector store with openai.beta.vectorStores.create() and passing in the newly created FILE IDs, and then creating the assistant with openai.beta.assistants.create() and passing the VECTOR STORE ID to the “tool_resources” property (tool_resources: {
    file_search: { vector_store_ids: […] },
    }). This is working great, but how do I update the vector store when the user uploads a new file at a later date?

Thanks,
Steve

1 Like

You should be able to use the Vector Store API to upload files to your Vector Store:

const vectorStore = getYourVectorStoreObjectFromSomewhere(...)

// To upload multiple files
openai.beta.vectorStores.fileBatches.uploadAndPoll(vectorStore.id, { files: [file1, file2] })

// To upload a single file
openai.beta.vectorStores.files.uploadAndPoll(vectorStore.id, file1)

I assume you need to store at least the Vector Store ID somewhere in your stateful app.

:bulb: You can also use upload instead of uploadAndPoll if you don’t need the polling mechanism.

Is this what you had in mind?

Thanks for the information. I ended up using openai.files.create() to upload the files and openai.beta.vectorStores.files.create() to add it to the vector store (passing the vector store Id and file Id from the openai.files.create() call). This method has worked well for my needs.