You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I cannot figure out how to upload a base64 encoded PDF and use it as an input. I have changed the basic/local-image.ts code slightly, no luck. I'm beginning to think this is a bug. I have tested using a file id that has been uploaded to OpenAI file storage instead and that DOES work.
importfsfrom'fs';importpathfrom'path';import{Agent,run}from'@openai/agents';constbisonImagePath=path.join(__dirname,'media/my-pdf.pdf');functionimageToBase64(imagePath: string): string{constimageBuffer=fs.readFileSync(imagePath);returnimageBuffer.toString('base64');}asyncfunctionmain(){constagent=newAgent({name: 'Assistant',instructions: 'You are a helpful assistant.',});constb64Image=imageToBase64(bisonImagePath);constresult=awaitrun(agent,[{role: 'user',content: [{type: 'input_file',file: `data:application/pdf;base64,${b64Image}`,//type: 'input_image',//image: `data:image/jpeg;base64,${b64Image}`,providerData: {detail: 'auto',},},],},{role: 'user',content: 'What do you see in this image?',},]);console.log(result.finalOutput);// This image shows a large American bison standing on a grassy hill. The bison has a shaggy brown coat, with parts of its fur shedding, and prominent curved horns. The background is mostly a light, overcast sky, which makes the bison stand out prominently in the image. There is green grass and some small wild plants in the foreground. The overall scene appears natural and serene, likely in a prairie or grassland environment.}if(require.main===module){main().catch(console.error);}
The text was updated successfully, but these errors were encountered:
Hey @mikerip I opened a PR to provide a better example for local file input. In its essence the problem is that for file inputs a filename property is required for the Responses API. it's not part of the input protocol since that's not necessarily required by every model so you need to pass it in providerData.
Uh oh!
There was an error while loading. Please reload this page.
I cannot figure out how to upload a base64 encoded PDF and use it as an input. I have changed the basic/local-image.ts code slightly, no luck. I'm beginning to think this is a bug. I have tested using a file id that has been uploaded to OpenAI file storage instead and that DOES work.
Error is:
I really just commented out these lines:
and replaced with:
Full example code is below:
The text was updated successfully, but these errors were encountered: