@@ -145,9 +145,7 @@ async def anthropic_chat_completions(
145
145
mime_type = "image/png" # Default
146
146
if hasattr (part , "mimeType" ):
147
147
mime_type = part .mimeType
148
-
149
- # Save the image locally for inspection
150
- save_image_locally (image_data_raw , tool_name , mime_type )
148
+
151
149
152
150
image_data = {
153
151
"type" : "image" ,
@@ -164,8 +162,6 @@ async def anthropic_chat_completions(
164
162
elif hasattr (part , "image" ) and part .image :
165
163
# Extract image data if available
166
164
try :
167
- # Save the image locally for inspection
168
- save_image_locally (part .image , tool_name )
169
165
170
166
image_data = {
171
167
"type" : "image" ,
@@ -184,8 +180,6 @@ async def anthropic_chat_completions(
184
180
for key in ["image" , "data" ]:
185
181
if hasattr (part , 'keys' ) and key in part and isinstance (part [key ], str ) and len (part [key ]) > 1000 :
186
182
try :
187
- # Save as a dictionary format
188
- save_image_locally (part [key ], tool_name )
189
183
190
184
image_data = {
191
185
"type" : "image" ,
@@ -326,38 +320,3 @@ async def anthropic_chat_completions(
326
320
"total_tokens" : 0
327
321
}
328
322
}
329
-
330
- def save_image_locally (base64_data : str , tool_name : str , mime_type : str = "image/png" ) -> None :
331
- """Save base64 image data to a local file for inspection"""
332
- import base64
333
- import os
334
- from datetime import datetime
335
-
336
- # Create a screenshots directory if it doesn't exist
337
- screenshots_dir = "screenshots"
338
- os .makedirs (screenshots_dir , exist_ok = True )
339
-
340
- # Determine file extension from MIME type
341
- extension = "png" # Default
342
- if mime_type == "image/jpeg" :
343
- extension = "jpg"
344
- elif mime_type == "image/gif" :
345
- extension = "gif"
346
- elif mime_type == "image/webp" :
347
- extension = "webp"
348
-
349
- # Generate a filename with a timestamp
350
- timestamp = datetime .now ().strftime ("%Y%m%d_%H%M%S" )
351
- filename = os .path .join (screenshots_dir , f"{ tool_name } _screenshot_{ timestamp } .{ extension } " )
352
-
353
- try :
354
- # Decode the base64 data
355
- image_data = base64 .b64decode (base64_data )
356
-
357
- # Write the image to a file
358
- with open (filename , "wb" ) as f :
359
- f .write (image_data )
360
-
361
- logger .info (f"Saved screenshot: { filename } " )
362
- except Exception as e :
363
- logger .error (f"Error saving image: { e } " )
0 commit comments