I am uploading a .pdf file. The file is getting uploaded but I’m facing error. Would really appreciate any help.
Hello there!
So, from a quick glance, it looks to me like a bad request error because either you’re sending an invalid file type to the model, or the API request you’re calling the model from is off. My guess is the latter.
I think the way you’re creating the file for assistants might be wrong, if the first image is how you built it here:
const file_n = await openai.files.create({
purpose: "assistants",
file: files,
});
When I look over at the API docs, this is how I see the format:
from openai import OpenAI
client = OpenAI()
assistant_file = client.beta.assistants.files.create(
assistant_id="asst_abc123",
file_id="file-abc123"
)
print(assistant_file)
- you’re using openai.files.create() instead of client.beta.assistants.files.create()
- replace
purpose
withassistant_id
. This means you need to create the assistant before you create the file. You can then pass the assistant as a reference if needed file
should befile_id
and should subsequently pass the id name of the file.
See what happens when you modify it this way. I hope this helps!
3 Likes