Spaces:
Running
on
Zero
Running
on
Zero
Vladyslav Humennyy
commited on
Commit
·
1af0400
1
Parent(s):
6cf522a
Try to fix as in previous versions was
Browse files
app.py
CHANGED
|
@@ -281,9 +281,16 @@ def _clean_history_for_display(history: list[dict[str, Any]]) -> list[dict[str,
|
|
| 281 |
for k, v in item.items():
|
| 282 |
if k == "_pil_image":
|
| 283 |
continue
|
| 284 |
-
if k == "alt_text"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
continue
|
| 286 |
cleaned_item[k] = v
|
|
|
|
|
|
|
|
|
|
| 287 |
cleaned_content.append(cleaned_item)
|
| 288 |
else:
|
| 289 |
cleaned_content.append(item)
|
|
@@ -294,9 +301,16 @@ def _clean_history_for_display(history: list[dict[str, Any]]) -> list[dict[str,
|
|
| 294 |
for k, v in content.items():
|
| 295 |
if k == "_pil_image":
|
| 296 |
continue
|
| 297 |
-
if k == "alt_text"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 298 |
continue
|
| 299 |
cleaned_item[k] = v
|
|
|
|
|
|
|
|
|
|
| 300 |
cleaned_message["content"] = cleaned_item
|
| 301 |
else:
|
| 302 |
cleaned_message["content"] = content
|
|
|
|
| 281 |
for k, v in item.items():
|
| 282 |
if k == "_pil_image":
|
| 283 |
continue
|
| 284 |
+
if k == "alt_text":
|
| 285 |
+
# Ensure alt_text is a string
|
| 286 |
+
if isinstance(v, str):
|
| 287 |
+
cleaned_item[k] = v
|
| 288 |
+
# Skip non-string alt_text values
|
| 289 |
continue
|
| 290 |
cleaned_item[k] = v
|
| 291 |
+
# Ensure alt_text exists for image type
|
| 292 |
+
if cleaned_item.get("type") == "image" and "alt_text" not in cleaned_item:
|
| 293 |
+
cleaned_item["alt_text"] = "uploaded image"
|
| 294 |
cleaned_content.append(cleaned_item)
|
| 295 |
else:
|
| 296 |
cleaned_content.append(item)
|
|
|
|
| 301 |
for k, v in content.items():
|
| 302 |
if k == "_pil_image":
|
| 303 |
continue
|
| 304 |
+
if k == "alt_text":
|
| 305 |
+
# Ensure alt_text is a string
|
| 306 |
+
if isinstance(v, str):
|
| 307 |
+
cleaned_item[k] = v
|
| 308 |
+
# Skip non-string alt_text values
|
| 309 |
continue
|
| 310 |
cleaned_item[k] = v
|
| 311 |
+
# Ensure alt_text exists for image content
|
| 312 |
+
if "path" in cleaned_item and "alt_text" not in cleaned_item:
|
| 313 |
+
cleaned_item["alt_text"] = "uploaded image"
|
| 314 |
cleaned_message["content"] = cleaned_item
|
| 315 |
else:
|
| 316 |
cleaned_message["content"] = content
|