When I wan't to use OpenAI Files API to gather file_id and later work with such hosted file, OpenAI chat client wrongly assume that hosted file is file part. I am uploading an image and when work with HostedFileContent, I am getting such error:
Invalid file data: 'file_id'. Expected a file with an application/pdf MIME type,
but got unsupported MIME type 'image/png'.
I have identified a line responsible for that:
|
(parts ??= []).Add(ResponseContentPart.CreateInputFilePart(fileContent.FileId)); |
When you take a look a few lines below (ChatRole.Tool), the HostedFileContent resolves type correctly based on MediaType.
|
Type = fc.HasTopLevelMediaType("image") ? "input_image" : "input_file", |
When I wan't to use OpenAI Files API to gather
file_idand later work with such hosted file, OpenAI chat client wrongly assume that hosted file is file part. I am uploading an image and when work with HostedFileContent, I am getting such error:Invalid file data: 'file_id'. Expected a file with an application/pdf MIME type,
but got unsupported MIME type 'image/png'.
I have identified a line responsible for that:
extensions/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Line 860 in a6b92c0
When you take a look a few lines below (ChatRole.Tool), the HostedFileContent resolves type correctly based on MediaType.
extensions/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Line 951 in a6b92c0