phidata
phidata copied to clipboard
Feature Proposal: Support Passing Images as Base64 in `agent.print_response` [ Official Standard Way ]
Description
Currently, the method add_images_to_message_content
supports adding images to message content through URLs.
- While the method already processes these inputs effectively, there is room for improvement to better support the use of base64-encoded images, Read PIL Image and also Byte Image.
The goal is to make it easier to directly pass base64-encoded image strings as input without requiring prior manual validation or transformations. This would streamline workflows for users who already work with base64 images in their pipelines.
Proposed Changes
Update the agent.print_response
functionality to explicitly accept and process base64-encoded image strings
.
Modify the logic in add_images_to_message_content
to prioritize and validate base64 strings more robustly.
PREVIEW CODE
agent.print_response(
[
{"type": "text", "text": "What's in this image, describe in 1 sentence"},
{
"type": "image_url",
"image_url": f"data:image/jpeg;base64,{base64_string}",
},
]
)
Lmk if you want me to pick this up and will get it done.
cc : @manthanguptaa @ashpreetbedi