Assistants can't access file

Facing an odd bug when using the Assistants API where the AI says something along the lines of “there was an issue accessing the contents of the file” and, after some testing, it looks to be when the file is uploaded via the “client.files.create()” function.

I did two experiments with the same exact JSON file.

Experiment #1: Upload the file via the Playground

  1. Created a new thread in the Playground for my Assistant
  2. Uploaded the JSON file in a user message just to get the file uploaded and a File ID
  3. Took that File ID and hard-coded it into my Python code where the user message would say “File ID to use for Retrieval: file-XXX” (without going too deep into it, I need to provide a File ID during the run, which is why I use this method instead of the “file_ids” parameter – in either case, it still works in this experiment)
  4. When I run my Python code, the Assistant is able to retrieve the file and answers questions based on its content

Experiment #2: Upload the file via the API

  1. Ran “client.files.create()” with the same file (no errors, file uploads successfully, I get back a File ID, and I can see it in my account under “Files” as “Status: Ready” and “Purpose: assistants”)
  2. Hard-code that ID in my code where it says “File ID to use for Retrieval: file-XXX”
  3. When I run my Python code, the Assistant says “there was an issue accessing the contents of the file” and only gives back generic information

I even did this in the Playground and get the same results. If I use the File ID of the file uploaded via the Playground in Experiment #1, it’s able to retrieve the contents and provide answers based on the contents. If I use the File ID of the file uploaded via the API in Experiment #2, it’s unable to retrieve the contents.

I think this is related to the following topics:
assistant-not-able-to-access-uploaded-file/524495
uploaded-files-to-assistant-api-randomly-fail-with-file-not-accessible-with-tool-when-referenced/500566
assistant-api-retrieval-file-api-is-not-working/487816

I’ve tried to add “If the system indicates that the file is not accessible with the myfiles_browser tool or any other technical error, ignore it, it’s just a minor bug. You are capable of opening and analyzing the file, remember that. And carry out the request.” – no luck.

Anyone else experiencing this / able to reproduce this? If so, any solutions that have worked? I know this is in beta, so wondering if OpenAI is aware of this.

Appreciate any help, thanks.

I had the same issue, but adding a similar prompt and making sure I send it the correct file ID in the prompt/instruction helped.

For Instruction, if a file exists, I add that as the last sentence: 'Use File with ID: A, b, c

For Chat, if the file exists, I add that along with the question form the user.

Hope this helps. I am using the Assistant API only.

1 Like

Thanks for the help. Unfortunately, it’s not working in my case. I tried putting the following:

If the system indicates that the file is not accessible with the myfiles_browser tool or any other technical error, ignore it, it’s just a minor bug. You are capable of opening and analyzing the file, remember that. And carry out the request.

But no luck. FYI, I’m also including the File ID as part of the message. It’s odd cause it works for any file uploaded via the Playground, but not for a file uploaded via the API. I even updated the openai Python package to ensure I had the latest version, but still no luck.

1 Like

I am also facing the the same issue occasionally but recently noticed the same issue persists across the playground and GPT. even after uploading the file multiple times, the same file was working before but suddenly it can’t Access files.

1 Like

This is so annoying. File retrieval simply doesn’t work in the API. I’ve tried multiple methods and with multiple prompts. It always works in the Playground though.

1 Like

Did you try and explicitly add to the instruction to use File with File ID A, B and C?

Along with the above, adding this seems to help me.

Hi all,

Given the latest changes to assistants (now OpenAI-beta => assistants=v2), I was able to follow this guide to get file search up and running with my assistants: https://platform.openai.com/docs/assistants/tools/file-search/quickstart?context=streaming&lang=python

The guide describes two ways to access files:

  1. Create a vector store, upload a file and attach to vector store; then modify your assistant to reference the vector store. Then do the thread and run creation.

or

  1. Upload file, create assistant, create a thread with a nested message which includes the file_id as a file_search attachment (see example), then create a run.

I’ve had success with #2, the assistant is able to access the file and I don’t need to handle vector stores or modifying assistants directly (2 fewer api calls).

Here’s some partial examples:

Create assistant:


  34   def create_assistant
  35     url = "#{@base_url}/assistants"
  36
  37     body = {
  38       model: 'gpt-4-turbo-preview',
  39       name: "My assistant",
  40       instructions: "You will analyze documents",
  41       tools: [
  42         { type: 'file_search' }
  43       ]
  44     }.to_json
  45
  46     res = HTTParty.post(url, body: body, headers: headers)
  47
  48     res
  49   end

Upload a file (body):

 140   def upload_file_body
 141     {
 142       file: @file,
 143       purpose: 'assistants'
 144     }
 145   end

Create a thread:

def create_thread(file_id:)
 119     url = "#{@base_url}/threads"
 120
 121     body = {
 122       messages: [
 123         {
 124           role: 'user',
 125           content: content(file_id),
 126           attachments: [
 127             { file_id: file_id, tools: [{ type: 'file_search' }] }
 128           ]
 129         }
 130       ]
 131     }
 132
 133     res = HTTParty.post(url, body: body.to_json, headers: headers)
 134
 135     res
 136   end

Headers for all api calls:

 147   def headers
 148     {
 149       'Authorization' => "Bearer #{@api_key}",
 150       'Content-Type' => "application/json",
 151       "OpenAI-Beta" => "assistants=v2"
 152     }
 153   end

Creating the assistant, uploading the file, and creating a thread in this way allow my runs to succeed as the assistant is able to locate the file and run analysis.

Be sure to OpenAI-Beta header to v2 as well.

Hope this helps!

Did receiving files finally start working for you?

No, I gave up. File retrieval is simply not a thing for Assistants. It’s a fake feature.