fix: Update image part handling to use inline_data for raw bytes in process_requested_tools
This commit is contained in:
parent
cde506052f
commit
2a4d097c2e
@ -667,7 +667,8 @@ async def process_requested_tools(cog: 'GurtCog', function_call: types.FunctionC
|
||||
clean_mime_type = image_mime_type.split(';')[0].lower()
|
||||
|
||||
if clean_mime_type in supported_image_mimes:
|
||||
image_part = types.Part(data=image_bytes, mime_type=clean_mime_type)
|
||||
# Corrected: Use inline_data for raw bytes
|
||||
image_part = types.Part(inline_data=types.Blob(data=image_bytes, mime_type=clean_mime_type))
|
||||
parts_to_return.append(image_part) # Corrected: Add to parts_to_return for this tool's response
|
||||
print(f"Added image part directly from get_user_avatar_data (MIME: {clean_mime_type}, {len(image_bytes)} bytes).")
|
||||
# Replace base64_data in the textual response to avoid sending it twice
|
||||
@ -721,7 +722,7 @@ async def process_requested_tools(cog: 'GurtCog', function_call: types.FunctionC
|
||||
|
||||
if clean_mime_type in supported_image_mimes:
|
||||
# Use types.Part.from_data instead of from_uri
|
||||
image_part = types.Part(data=image_bytes, mime_type=clean_mime_type)
|
||||
image_part = types.Part(inline_data=types.Blob(data=image_bytes, mime_type=clean_mime_type))
|
||||
parts_to_return.append(image_part)
|
||||
download_success = True
|
||||
print(f"Added image part (from data, {len(image_bytes)} bytes, MIME: {clean_mime_type}) from tool '{function_name}' result.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user