Assistants V2 : Message with question about file content does not work

Hello,

I am trying in vain to ask my OpenAI assistant for information on a previously uploaded file. I first performed the necessary actions on the Playground. Thanks to the log, I can see the various calls that are sent to the API. On the Playground, it works without any issues.

However, when I try to do it programmatically, it doesn’t work. Here’s what I do:

  1. I upload a PDF file and i take its ID (in this case file-RMQrNqFFNb4cHFKey41CJxSw)
  2. I create a thread.
  3. I create a message on the thread with the following request:
POST https://api.openai.com/v1/threads/thread_MyThreadId/messages
Content-Type: application/json
Authorization: Bearer my_open_ai_KEY
OpenAI-Beta: assistants=v2

{
    "attachments": [
        {
            "file_id": "file-RMQrNqFFNb4cHFKey41CJxSw",
            "tools": [
                {
                    "type": "file_search"
                }
            ]
        }
    ],
    "content": [
        {
            "text": "could you please summarize the content of the file?",
            "type": "text"
        }
    ],
    "role": "user"
}

The model’s response is always something like:
It seems that the file has not been uploaded yet. Please upload the file so I can assist you with summarizing its content.

What am I doing wrong?

Probably because you’re using the v1 endpoint: POST https://api.openai.com/v1/threads/thread_MyThreadId/messages

Hi,

I’ve finally found where was my problem.

The API to use is well V1 , but Assistants must be v2 all the way through the API calls.

In my logic, I’ve used partially the Azure OpenAI function library to do API calls directly to OpenAI (I do not use the service from Azure).
The official Azure OpenAI library used assistants=v1 iand not v2.

Mixing calls with assistants=v1 and v2 does not generate any errors but you get some unexpected results.

Now I’ve written in C# all my API calls using assistants=v2 and it works perfectly.

I hope that the Azure library will be updated soon with assistants v2.

Regards,
F.

1 Like