Assistants API v2 using code interpreter can't find uploaded files

Since yesterday I’m trying to use uploaded files via code interpreter, but can’t get it to work with assistants API v2.

I adhere to the docs: https://platform.openai.com/docs/api-reference/messages

with open(tmp_file_path, "rb") as file:
                    uploaded_file = client.files.create(file=file, purpose="assistants")
                    attachments.append(
                        {
                            "file_id": uploaded_file.id,
                            "tools": [{"type": "code_interpreter"}],
                        }
                    )

attachments is later added to the assistants message.

The file is shown as successfully uploaded in the UI:

The assistant can correctly use tools like duckduckgo, custom tools, and I can download files created via code interpreter.

But when I upload a file and ask something about it, I always receive something along these lines as an answer: I can't find the file with this path

Is anybody else able to upload files to code interpreter using the v2 api?

OS: Ubuntu
OpenAI python SDK version: openai-1.30.4

Known bug for weeks now. Still waiting for an update on when it will be fixed.

1 Like

thank you for the answer!

Just so that I won’t open a ticket again for known stuff, could you let me know where you know this from?

I was actually checking this forum, github issues as well as discord but couldn’t find this exact bug.

I’ve had email discussions back and forth with one of the engineers, so I know they’re on it, I just figure it’s a lot more complicated to fix than they originally thought.

You can check my posts, I’ve been asking about it for weeks now, so there are a couple of them.

1 Like

client.files doesn’t work in V2.

It does work in v2, the files are successfully uploaded, I can find them in the storage area of the Openai platform UI.

Hey jim, do you know whether they already resolved this?

Just came back checking, but seems like it’s still the same issue and Assistants API v2 can’t see any attached files.

I’m not really sure, I kinda gave up after awhile as I’m pretty sure I fell off their radar. I get the feeling that it’s really up to us to do as best we can given what is available rather than trying to send in bug reports, etc.

What I ended up doing, if it helps, is briefly running over the uploaded file and generating a brief “summary” first paragraph, and then appending that to the start of the conversation.

Something about that triggers the lookup semantically, and from there on it always scans the uploaded file as part of its response. Haven’t really had any issues since I started doing this.

Also thought about doing this.

However, the power of code interpreter is handling the actual files imo, e.g. converting a .jpg to a .png

thanks for the answer!

Guess what, I does work now with Assistants API v2!

Today it wasn’t OpenAI, but the langchain library that caused problems.

When using the vanilla OpenAI python sdk, I can successfully upload files and the LLM can find them.

Links that show how it’s done:
https://platform.openai.com/docs/assistants/deep-dive/creating-assistants

https://platform.openai.com/docs/assistants/tools/code-interpreter?lang=python

1 Like