wenjin272 opened a new issue, #1195:
URL: https://github.com/apache/flink-agents/issues/1195

   ### Search before asking
   
   - [x] I searched existing issues for duplicates; related work is linked 
below where applicable.
   
   ### Description
   
   This is a child issue of #1055.
   
   #### Problem
   
   Image, Audio, Video, and Document blocks expose Base64-string and URL 
factories but no raw-bytes factory. File reads and generated media commonly 
produce bytes, so callers must repeat Base64 encoding and string conversion 
before constructing a block.
   
   #### Proposed direction
   
   Add Python `from_bytes(media_type, data, ...)` and Java 
`fromBytes(mediaType, byte[])` consistently for all four block types. Encode 
raw bytes once using standard Base64 without line wrapping and construct the 
existing Base64Source representation.
   
   - Keep `from_base64`/`fromBase64` as already-encoded-string entry points; do 
not guess the encoding or encode their input again.
   - Retain explicit media type input and existing optional metadata 
conventions.
   - Reject null/invalid input types and empty bytes consistently with the 
current non-empty inline-payload contract.
   - Encode at construction and do not retain the caller's mutable Java byte 
array.
   - Preserve the existing serialized source shape and provider/bridge 
behavior; no new raw-binary wire representation is needed.
   
   Strict validation of the existing Base64-string entry point is a separate 
compatibility decision. Currently Base64Source validates a non-empty string, 
not full Base64 syntax; document this accurately rather than silently changing 
that contract in this convenience addition.
   
   #### Acceptance criteria
   
   - Matching Java/Python factories on Image, Audio, Video, and Document blocks.
   - Tests cover arbitrary binary values (including non-UTF-8 bytes), Base64 
padding, invalid/empty inputs, and Java input-array mutation after construction.
   - Serialization/cross-language and representative provider conversion 
preserve the same bytes as the existing Base64 entry point; logging remains 
payload-safe.
   - Examples show raw bytes and already-encoded strings as separate entry 
points, and retain URL sources for externally managed media.
   
   Relevant code: `python/flink_agents/api/chat_message.py`, 
`api/.../chat/messages/Base64Source.java` and concrete media blocks.
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!
   


-- 
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