feat: add placeholder for image inputs in Anthropic proxy [LET-6449] (#6522)

- Add [IMAGE] placeholder when extracting user messages with image content blocks
- Allows LLM to know images were present in conversation history
- LLM can infer context from surrounding text and conversation flow

🐙 Generated with [Letta Code](https://letta.com)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
cthomas
2025-12-05 11:53:43 -08:00
committed by Caren Thomas
parent e5bda413c0
commit 0d18ecc2ec

View File

@@ -34,8 +34,11 @@ def extract_user_messages(body: bytes) -> list[str]:
user_messages.append(content)
elif isinstance(content, list):
for block in content:
if isinstance(block, dict) and block.get("type") == "text":
user_messages.append(block.get("text", ""))
if isinstance(block, dict):
if block.get("type") == "text":
user_messages.append(block.get("text", ""))
elif block.get("type") == "image":
user_messages.append("[IMAGE]")
return user_messages
except Exception as e: