fix(agent): handle image context content parsing more robustly

This commit is contained in:
sharath 2025-06-01 10:15:20 +00:00
parent eee722a42e
commit 05e4c5d901
No known key found for this signature in database
1 changed files with 1 additions and 1 deletions

View File

@ -180,7 +180,7 @@ async def run_agent(
latest_image_context_msg = await client.table('messages').select('*').eq('thread_id', thread_id).eq('type', 'image_context').order('created_at', desc=True).limit(1).execute()
if latest_image_context_msg.data and len(latest_image_context_msg.data) > 0:
try:
image_context_content = json.loads(latest_image_context_msg.data[0]["content"])
image_context_content = latest_image_context_msg.data[0]["content"] if isinstance(latest_image_context_msg.data[0]["content"], dict) else json.loads(latest_image_context_msg.data[0]["content"])
base64_image = image_context_content.get("base64")
mime_type = image_context_content.get("mime_type")
file_path = image_context_content.get("file_path", "unknown file")