-
-
Notifications
You must be signed in to change notification settings - Fork 140
Open
Labels
BugSomething isn't workingSomething isn't workingPlatformIssues & PRs about the AI Platform componentIssues & PRs about the AI Platform componentStatus: Needs Review
Description
Describe Your Problem 🎯
What happened
The OpenAI document normalizer is sending files as base64-encoded file_data in message content, but the OpenAI API expects a file_id reference instead.
Expected behavior
Files should be uploaded to OpenAI's /v1/files endpoint first to obtain a file_id, then that file_id should be used in the message content format:
[
'type' => 'file',
'file' => [
'file_id' => 'file-6F2ksmvXxt4VdoqmHRw6kL'
]
]Actual behavior
The normalizer currently returns:
[
'type' => 'file',
'file' => [
'filename' => 'document.pdf',
'file_data' => 'base64encodedstring...'
]
]Steps to reproduce
- Create a
DocumentorFileobject with file content - Use it in a message sent to OpenAI via the Symfony AI Platform
- Observe that the request contains base64
file_datainstead of afile_id - The API may reject or fail to process the file correctly
Provide Detailed Information 📋
#file: "./src/InvoiceProcessing/Infrastructure/Agent/AbstractSymfonyAiAgent.php"
#line: 77
-previous: Symfony\AI\Platform\Exception\BadRequestException^ {#17750
#message: "Missing required parameter: 'messages[1].content[1].file.file_id'."
#code: 0
#file: "./vendor/symfony/ai-platform/src/Bridge/OpenAi/Gpt/ResultConverter.php"
Component version
- Symfony AI Platform: dev-main
Error messages
#file: "./src/InvoiceProcessing/Infrastructure/Agent/AbstractSymfonyAiAgent.php"
#line: 77
-previous: Symfony\AI\Platform\Exception\BadRequestException^ {#17750
#message: "Missing required parameter: 'messages[1].content[1].file.file_id'."
#code: 0
#file: "./vendor/symfony/ai-platform/src/Bridge/OpenAi/Gpt/ResultConverter.php"
Additional context
According to OpenAI's API documentation, files should be:
- Uploaded to
POST https://api.openai.com/v1/fileswith:purpose: "user_data" (or appropriate purpose)file: multipart file uploadexpires_after: optional expiration setting
- The returned
file_idshould then be used in message content
Impact
- Large files cause oversized request payloads
- May hit API size limits
- Doesn't follow OpenAI's recommended file handling approach
- Inefficient for repeated file usage (file must be re-embedded each time)
Reference
- OpenAI Files API: https://platform.openai.com/docs/api-reference/files/create
- OpenAI Message Content: https://platform.openai.com/docs/api-reference/messages/create#messages-create-content
Metadata
Metadata
Assignees
Labels
BugSomething isn't workingSomething isn't workingPlatformIssues & PRs about the AI Platform componentIssues & PRs about the AI Platform componentStatus: Needs Review