Spaces:
Running on Zero
Running on Zero
Fix history filter dropping every message: model never saw user input
Browse files
app.py
CHANGED
|
@@ -695,7 +695,11 @@ def _history_for_model(history: list) -> list[dict]:
|
|
| 695 |
conversation = [{"role": "system", "content": SYSTEM_PROMPT}]
|
| 696 |
for msg in history or []:
|
| 697 |
role = msg.get("role", "user")
|
| 698 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 699 |
continue
|
| 700 |
content = msg.get("content", "")
|
| 701 |
if isinstance(content, list):
|
|
|
|
| 695 |
conversation = [{"role": "system", "content": SYSTEM_PROMPT}]
|
| 696 |
for msg in history or []:
|
| 697 |
role = msg.get("role", "user")
|
| 698 |
+
meta = msg.get("metadata") or {}
|
| 699 |
+
# Only skip thought/tool bubbles; Gradio attaches an empty metadata
|
| 700 |
+
# dict to ordinary messages, so a bare truthiness check drops them all.
|
| 701 |
+
is_thought = isinstance(meta, dict) and bool(meta.get("title"))
|
| 702 |
+
if role == "system" or is_thought:
|
| 703 |
continue
|
| 704 |
content = msg.get("content", "")
|
| 705 |
if isinstance(content, list):
|