From 742a67d09d4da3189c6fafb16213477019c49568 Mon Sep 17 00:00:00 2001 From: Shoubhit Dash Date: Tue, 28 Oct 2025 00:05:20 +0530 Subject: [PATCH] fix non-string content handling for multimodal messages --- packages/openai-sdk-python/src/supermemory_openai/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/openai-sdk-python/src/supermemory_openai/utils.py b/packages/openai-sdk-python/src/supermemory_openai/utils.py index fa885dda..a2a0bab1 100644 --- a/packages/openai-sdk-python/src/supermemory_openai/utils.py +++ b/packages/openai-sdk-python/src/supermemory_openai/utils.py @@ -121,8 +121,13 @@ def inject_memories_into_messages( content = message.get("content", "") if isinstance(content, str): updated_content = f"{content}\n\n{memories}" + elif isinstance(content, list): + # Handle multimodal content - append text to existing text parts or add new text part + updated_content = list(content) # Copy the list + # Add memories as a new text part + updated_content.append({"type": "text", "text": f"\n\n{memories}"}) else: - # If content is not a string, just append as string + # Fallback: convert to string and append updated_content = f"{content}\n\n{memories}" updated_message = dict(message)