Assistant API not working with Retrieval Tool with gpt4-turbo

I want to ask my Assistant questions using uploaded files as a knowledge base using the Retrieval tool, but it’s not working.

I have an Assistant created and files manually uploaded to it. I can see the files have been successfully uploaded and attached to the Assistant.

In the playground, I can directly ask questions and get responses that pull from these files. However, when I try to use code to handle this, it gives me a generic LLM answer.

The only difference between the code and the playground is that we add some historical data into the instructions (the user’s profile data).

Has anyone gotten this to work properly?

1 Like


Just adding the files to the assistant gave unreliable results. No idea why it fails - the doc leads one to believe it should work.

This is what I had to do:

  1. add the files to assistant
  2. I added the assistant files to the createMessage call. as fileids for the createMessage

I am not sure step 1 is needed if step 2 is done. Have not had the chance that scenario.

Would be interested to see what your experience is.


I had the same issue before but I was miss using the openai sdk, I moved to the vercel/ai sdk.

You can look at my app on github to see how I coded it OpenAssistantGPT/app/api/chatbots/[chatbotId]/chat/route.ts at main · marcolivierbouch/OpenAssistantGPT · GitHub

1 Like

I have at times have to be a VERY specific in the prompts to FORCE the model to use the files. It helps to make sure the files are uploaded with a specific name to refer to them by that name as well.

1 Like

As another data point:

Even though azureai version of Assistant does not officially support the retrieval tool yet, by adding the files to the createMessage makes it work nicely in azureai Assistant. I do not have to refer to the filename in the prompts in either case.

Even though I have it working, I am uneasy that this approach (or any for that matter) is not backed by definitive documentation on what the correct process is. So it might all break on the next push.

On that happy thought