Spaces:
Running on Zero
Running on Zero
Extract text from Gradio 6 content blocks: model was receiving empty user turns
Browse files
app.py
CHANGED
|
@@ -703,7 +703,16 @@ def _history_for_model(history: list) -> list[dict]:
|
|
| 703 |
continue
|
| 704 |
content = msg.get("content", "")
|
| 705 |
if isinstance(content, list):
|
| 706 |
-
content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 707 |
if role == "assistant":
|
| 708 |
content = _strip_thinking(content)
|
| 709 |
if content:
|
|
|
|
| 703 |
continue
|
| 704 |
content = msg.get("content", "")
|
| 705 |
if isinstance(content, list):
|
| 706 |
+
# Gradio 6 sends message content as a list of blocks.
|
| 707 |
+
parts = []
|
| 708 |
+
for block in content:
|
| 709 |
+
if isinstance(block, str):
|
| 710 |
+
parts.append(block)
|
| 711 |
+
elif isinstance(block, dict):
|
| 712 |
+
text = block.get("text") or block.get("content") or ""
|
| 713 |
+
if isinstance(text, str) and text:
|
| 714 |
+
parts.append(text)
|
| 715 |
+
content = "\n".join(parts)
|
| 716 |
if role == "assistant":
|
| 717 |
content = _strip_thinking(content)
|
| 718 |
if content:
|