From 2a4d097c2e3ece43288a69cb6f19867753a03ddd Mon Sep 17 00:00:00 2001 From: Slipstream Date: Wed, 28 May 2025 08:48:33 -0600 Subject: [PATCH] fix: Update image part handling to use inline_data for raw bytes in process_requested_tools --- gurt/api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gurt/api.py b/gurt/api.py index 38b383c..2cfc395 100644 --- a/gurt/api.py +++ b/gurt/api.py @@ -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.")