mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-08-27 14:17:10 -04:00
Fix 'list' object has no attribute 'strip' error
Handle multimodal messages (images) where content is a list instead of string. Skip non-string content in LLMLingua and code-aware compression transforms.
This commit is contained in:
parent
e6370026bc
commit
07dfa9d25c
2 changed files with 9 additions and 2 deletions
|
|
@ -1201,7 +1201,8 @@ class CodeAwareCompressor(Transform):
|
|||
for message in messages:
|
||||
content = message.get("content", "")
|
||||
|
||||
if not content:
|
||||
# Skip empty or non-string content (multimodal messages with images)
|
||||
if not content or not isinstance(content, str):
|
||||
transformed_messages.append(message)
|
||||
continue
|
||||
|
||||
|
|
@ -1266,7 +1267,8 @@ class CodeAwareCompressor(Transform):
|
|||
|
||||
for message in messages:
|
||||
content = message.get("content", "")
|
||||
if content:
|
||||
# Only check string content (skip multimodal)
|
||||
if content and isinstance(content, str):
|
||||
detection = detect_content_type(content)
|
||||
if detection.content_type == ContentType.SOURCE_CODE:
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -430,6 +430,11 @@ class LLMLinguaCompressor(Transform):
|
|||
role = message.get("role", "")
|
||||
content = message.get("content", "")
|
||||
|
||||
# Skip non-string content (multimodal messages with images)
|
||||
if not isinstance(content, str):
|
||||
transformed_messages.append(message)
|
||||
continue
|
||||
|
||||
# Compress tool results (highest value compression)
|
||||
if role == "tool" and content:
|
||||
result = self.compress(content, context=context, content_type="json")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue