The Assistants API cannot access files for some reason

For some reason, every time I attach a file_id to a message, the assistant cannot retrieve it. The purpose of the file is for retrieval. I would always get a message along the lines of this:

I’m sorry, but as an AI, I do not have the capability to download or view files. However, you can tell me about the contents of the document or ask questions, and I will do my best to provide relevant and accurate information based on the data and knowledge I have been trained on up until April 2023.

And some other variations of this message.

Here’s a sample code:

thread = client.beta.threads.create()

message = client.beta.threads.messages.create(
    thread_id=thread.id,
    role="user",
    content="Tell me about this document.",
    file_ids=["file-xxx"],
)

run = client.beta.threads.runs.create(
    thread_id=thread.id, assistant_id="asst_xxx"
)

while True:
    time.sleep(5)
    retrieve_run = client.beta.threads.runs.retrieve(thread_id=thread.id, run_id=run.id)

    if retrieve_run.status == "completed":
        break

messages = client.beta.threads.messages.list(thread_id=thread.id)

Has anyone encountered the same issue? I would like to know how you solved it. Thanks!

I had the same issue earlier today - and then a few hours later it worked again as expected. I suspect this is just the consequence of work being done behind the curtains on the API.

Tried it out again, and somehow it now works. Previously it would fail 100% of the time.

Whenever I mention the word “document” in my prompt, it seems to be able to find the file. However if I don’t mention the word “document”, it’s kind of a hit or miss.

Also, sometimes when it does detect the file, it will mention things like:

I’m unable to access the entire document, but based on the sections I was able to review, it appears to be related to…

or something like

The file seems to be an … However, the text appears to be corrupted or garbled, making it difficult to comprehend.

Would you mind telling me the instructions that you gave to the assistant?

1 Like

The file seems to be an … However, the text appears to be corrupted or garbled, making it difficult to comprehend.

Yeah I’m seeing this exact language for many of my requests as well. Has anyone found a solution here or gotten the attention of the OAI team?

Still experiencing this for PDFs on December 11th with both GPT-4 preview and 3.5-turbo.

I am using the following code with gpt-4-turbo-preview, which is copied directly from the OpenAI documentation:

thread = client.beta.threads.create(
            messages=[
                {
                    "role": "user",
                    "content": "my prompt"
                    "file_ids": [file1.id],
                }
            ]
        )

Every time I run it, I get some version of this message:
I’m sorry, but I can’t directly access or analyze the content of files uploaded. However, if you could provide some details or excerpts from the documents, I would be happy to help analyze those based on the instructions you’ve provided.

I read from others in this chain that it may be an intermittent problem. However, it has not worked for me no matter how many times I run it over the past few days.

I am assuming the problem is on OpenAI’s end and not with the code. If on their end, has anyone come up with a workaround?

FIX: Rookie Mistake. I misunderstood the documentation. I thought that, because I was not storing the docs with the Assistant, that I did not need to turn “Retrieval” on for the assistant. Once I did that, everything worked fine.