Croway opened a new pull request, #23970:
URL: https://github.com/apache/camel/pull/23970

   ## Description
   
   Fixes [CAMEL-23739](https://issues.apache.org/jira/browse/CAMEL-23739).
   
   The `chat-completion` operation only accepted `java.io.File` bodies for 
vision/image input. Bodies produced by file-based and cloud storage consumers 
(`WrappedFile`/`GenericFile` from file/FTP/SFTP, `byte[]`/`InputStream` from 
AWS S3, Azure Blob, etc.) fell through to text handling, corrupting binary 
image content. MIME detection also relied solely on `Files.probeContentType()`, 
which returns `null` on macOS for many paths.
   
   ### Changes
   
   - `OpenAIProducer.buildUserMessage()` now dispatches on `WrappedFile`, 
`File`, `Path`, `byte[]` and `InputStream` bodies (same pattern as 
`OpenAIAudioTranscriptionProducer`)
   - `WrappedFile` wrapping a local `java.io.File` is used by path directly; 
remote files (FTP/SFTP) resolve the MIME type from headers/file name **before** 
streaming the content via the type converter, so large unsupported payloads are 
rejected without being read into memory
   - New `MimeTypeHelper` with header-priority MIME resolution: 
`CamelOpenAIMediaType` (new header) → `CamelFileContentType` / cloud storage 
content-type headers (S3, Azure Blob/Data Lake, GCS, MinIO, IBM COS) → 
`Content-Type` → system probing → file extension fallback
   - Backward compatible: `byte[]`/`InputStream` bodies without an image MIME 
type keep the previous text behavior
   - New `OpenAIVisionBodyTypesMockTest` (9 tests, including a real `file:` 
consumer route) asserting the base64 data URL in the outgoing request decodes 
to the original bytes
   - Component docs updated (input handling, MIME detection priority, cloud 
storage examples) and 4.21 upgrade guide entry added
   
   _Claude Code on behalf of Federico Mariani_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to