Repository navigation
What is the recommended way to add image to LLM chat history after calling a tool? #809
|
If a tool calling returns an image instead of texts, how to add it properly to the chat history? My workaround is def load_screenshot(tool_context: ToolContext):
""" Load the system screenshot from clipboard.
"""
if image_bytes := get_clipboard_image():
tool_context._invocation_context.user_content.parts.append(
types.Part.from_bytes(
data=image_bytes,
mime_type="image/png"
)
)
return "Successfully load screenshot from clipboard."
else:
return "Failed to load screenshot from clipboard."Considering |
Answered by
seanzhou1023
May 20, 2025
Replies: 1 comment 1 reply
|
I don't think it's a right way to do it. Mainly:
I don't think we support blob as function response, maybe you can try base64 encoding ? |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
since response is of type dict[str, Any], you may try put types.Blob as one of the value in the dict.