Spaces:
Build error
Build error
Commit ·
07dfa9d
1
Parent(s): e637002
Fix 'list' object has no attribute 'strip' error
Browse filesHandle multimodal messages (images) where content is a list instead of string.
Skip non-string content in LLMLingua and code-aware compression transforms.
headroom/transforms/code_compressor.py
CHANGED
|
@@ -1201,7 +1201,8 @@ class CodeAwareCompressor(Transform):
|
|
| 1201 |
for message in messages:
|
| 1202 |
content = message.get("content", "")
|
| 1203 |
|
| 1204 |
-
|
|
|
|
| 1205 |
transformed_messages.append(message)
|
| 1206 |
continue
|
| 1207 |
|
|
@@ -1266,7 +1267,8 @@ class CodeAwareCompressor(Transform):
|
|
| 1266 |
|
| 1267 |
for message in messages:
|
| 1268 |
content = message.get("content", "")
|
| 1269 |
-
|
|
|
|
| 1270 |
detection = detect_content_type(content)
|
| 1271 |
if detection.content_type == ContentType.SOURCE_CODE:
|
| 1272 |
return True
|
|
|
|
| 1201 |
for message in messages:
|
| 1202 |
content = message.get("content", "")
|
| 1203 |
|
| 1204 |
+
# Skip empty or non-string content (multimodal messages with images)
|
| 1205 |
+
if not content or not isinstance(content, str):
|
| 1206 |
transformed_messages.append(message)
|
| 1207 |
continue
|
| 1208 |
|
|
|
|
| 1267 |
|
| 1268 |
for message in messages:
|
| 1269 |
content = message.get("content", "")
|
| 1270 |
+
# Only check string content (skip multimodal)
|
| 1271 |
+
if content and isinstance(content, str):
|
| 1272 |
detection = detect_content_type(content)
|
| 1273 |
if detection.content_type == ContentType.SOURCE_CODE:
|
| 1274 |
return True
|
headroom/transforms/llmlingua_compressor.py
CHANGED
|
@@ -430,6 +430,11 @@ class LLMLinguaCompressor(Transform):
|
|
| 430 |
role = message.get("role", "")
|
| 431 |
content = message.get("content", "")
|
| 432 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 433 |
# Compress tool results (highest value compression)
|
| 434 |
if role == "tool" and content:
|
| 435 |
result = self.compress(content, context=context, content_type="json")
|
|
|
|
| 430 |
role = message.get("role", "")
|
| 431 |
content = message.get("content", "")
|
| 432 |
|
| 433 |
+
# Skip non-string content (multimodal messages with images)
|
| 434 |
+
if not isinstance(content, str):
|
| 435 |
+
transformed_messages.append(message)
|
| 436 |
+
continue
|
| 437 |
+
|
| 438 |
# Compress tool results (highest value compression)
|
| 439 |
if role == "tool" and content:
|
| 440 |
result = self.compress(content, context=context, content_type="json")
|