Hi,
I am uploading an image to my open ai storage.
My upload code is this:
uploadedImage = await openai.files.create({ file: await toFile(filePart.data, filePart.filename, { type: filePart.type }), purpose: 'assistants' });
The upload works find and I am able to inspect the image via the web, being able to verify the correct name and suffix.
When I start a thread with messages referring to this image, the thread starts running and then abruptly ends with an error message.
last_error: {
code: 'invalid_image_format',
message: "You uploaded an unsupported image. Please make sure your image is below 20 MB in size and is of one the following formats: ['png', 'jpeg', 'gif', 'webp']."
},
If I change the upload to a fetch function to download a random image from my public storage, it works fine, as in, the newly uploaded image is being used by the thread, the thread is running and producing a response.
With the same image uploaded through an in memory stream it doesnt work.
The image is 4.3mb and I tried uploading jpeg and png, but both times it complains about a wrong format, which I cannot really understand why.
openIAQueries.push({
role: 'user',
content: [
{
"type": "text",
"text": "What's in this image?"
},
{
"type": "image_file",
"image_file": {
"file_id": uploadedImageId,
}
},
],
});
const thread = await openai.beta.threads.create({
messages: openIAQueries,
});
let run = await openai.beta.threads.runs.create(
thread.id,
{ assistant_id: assistant.id }
);
while (run.status === "queued" || run.status === "in_progress") {
run = await openai.beta.threads.runs.retrieve(thread.id, run.id);
console.log(`Run status: ${run.status}\n`);
}
this is how I run my thread.
I am confused why everything is working when I use the fetch function, but not working when I upload the in memory image.
Thank you for any help