Spaces:
Paused
Paused
Filter empty thoughts from recording and chat display
Browse files- agent_core.py +6 -4
- bqsm_assist/agent_core.py +6 -4
- bqsm_assist/phoenix_dashboard.py +2 -2
- phoenix_dashboard.py +2 -2
agent_core.py
CHANGED
|
@@ -309,18 +309,20 @@ def run_agent(user_msg, generate, history=None, on_event=None, contemplate=False
|
|
| 309 |
for round_n in range(rounds):
|
| 310 |
text = generate(render(msgs), 256).strip()
|
| 311 |
emit({"type": "model", "round": round_n, "text": text})
|
| 312 |
-
|
|
|
|
| 313 |
|
| 314 |
-
t = parse_tool(text)
|
| 315 |
if not t:
|
| 316 |
# No tool call. In contemplate mode: record + keep going.
|
| 317 |
if contemplate:
|
| 318 |
-
|
|
|
|
| 319 |
msgs.append({"role": "user",
|
| 320 |
"content": "Continue your thoughts. What else do "
|
| 321 |
"you observe or conclude?"})
|
| 322 |
continue
|
| 323 |
-
return text, events
|
| 324 |
|
| 325 |
tool, params = t
|
| 326 |
dedup = f"{tool}|{params}"
|
|
|
|
| 309 |
for round_n in range(rounds):
|
| 310 |
text = generate(render(msgs), 256).strip()
|
| 311 |
emit({"type": "model", "round": round_n, "text": text})
|
| 312 |
+
if text:
|
| 313 |
+
record_thought(text, round_n)
|
| 314 |
|
| 315 |
+
t = parse_tool(text) if text else None
|
| 316 |
if not t:
|
| 317 |
# No tool call. In contemplate mode: record + keep going.
|
| 318 |
if contemplate:
|
| 319 |
+
if text:
|
| 320 |
+
msgs.append({"role": "assistant", "content": text})
|
| 321 |
msgs.append({"role": "user",
|
| 322 |
"content": "Continue your thoughts. What else do "
|
| 323 |
"you observe or conclude?"})
|
| 324 |
continue
|
| 325 |
+
return (text or "(no response)"), events
|
| 326 |
|
| 327 |
tool, params = t
|
| 328 |
dedup = f"{tool}|{params}"
|
bqsm_assist/agent_core.py
CHANGED
|
@@ -309,18 +309,20 @@ def run_agent(user_msg, generate, history=None, on_event=None, contemplate=False
|
|
| 309 |
for round_n in range(rounds):
|
| 310 |
text = generate(render(msgs), 256).strip()
|
| 311 |
emit({"type": "model", "round": round_n, "text": text})
|
| 312 |
-
|
|
|
|
| 313 |
|
| 314 |
-
t = parse_tool(text)
|
| 315 |
if not t:
|
| 316 |
# No tool call. In contemplate mode: record + keep going.
|
| 317 |
if contemplate:
|
| 318 |
-
|
|
|
|
| 319 |
msgs.append({"role": "user",
|
| 320 |
"content": "Continue your thoughts. What else do "
|
| 321 |
"you observe or conclude?"})
|
| 322 |
continue
|
| 323 |
-
return text, events
|
| 324 |
|
| 325 |
tool, params = t
|
| 326 |
dedup = f"{tool}|{params}"
|
|
|
|
| 309 |
for round_n in range(rounds):
|
| 310 |
text = generate(render(msgs), 256).strip()
|
| 311 |
emit({"type": "model", "round": round_n, "text": text})
|
| 312 |
+
if text:
|
| 313 |
+
record_thought(text, round_n)
|
| 314 |
|
| 315 |
+
t = parse_tool(text) if text else None
|
| 316 |
if not t:
|
| 317 |
# No tool call. In contemplate mode: record + keep going.
|
| 318 |
if contemplate:
|
| 319 |
+
if text:
|
| 320 |
+
msgs.append({"role": "assistant", "content": text})
|
| 321 |
msgs.append({"role": "user",
|
| 322 |
"content": "Continue your thoughts. What else do "
|
| 323 |
"you observe or conclude?"})
|
| 324 |
continue
|
| 325 |
+
return (text or "(no response)"), events
|
| 326 |
|
| 327 |
tool, params = t
|
| 328 |
dedup = f"{tool}|{params}"
|
bqsm_assist/phoenix_dashboard.py
CHANGED
|
@@ -859,8 +859,8 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
|
| 859 |
elif e["type"] == "model":
|
| 860 |
add_verbose({"tag": "chat",
|
| 861 |
"data": f"model[{e['round']}]: {e['text'][:120]}"})
|
| 862 |
-
# In contemplate mode, surface
|
| 863 |
-
if CONTEMPLATE and e.get("
|
| 864 |
with _chat_lock:
|
| 865 |
_chat_messages.append({"role": "phox",
|
| 866 |
"text": f"[thought #{e['round']}] {e['text'][:200]}"})
|
|
|
|
| 859 |
elif e["type"] == "model":
|
| 860 |
add_verbose({"tag": "chat",
|
| 861 |
"data": f"model[{e['round']}]: {e['text'][:120]}"})
|
| 862 |
+
# In contemplate mode, surface non-empty thoughts
|
| 863 |
+
if CONTEMPLATE and e.get("text", "").strip():
|
| 864 |
with _chat_lock:
|
| 865 |
_chat_messages.append({"role": "phox",
|
| 866 |
"text": f"[thought #{e['round']}] {e['text'][:200]}"})
|
phoenix_dashboard.py
CHANGED
|
@@ -859,8 +859,8 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
|
| 859 |
elif e["type"] == "model":
|
| 860 |
add_verbose({"tag": "chat",
|
| 861 |
"data": f"model[{e['round']}]: {e['text'][:120]}"})
|
| 862 |
-
# In contemplate mode, surface
|
| 863 |
-
if CONTEMPLATE and e.get("
|
| 864 |
with _chat_lock:
|
| 865 |
_chat_messages.append({"role": "phox",
|
| 866 |
"text": f"[thought #{e['round']}] {e['text'][:200]}"})
|
|
|
|
| 859 |
elif e["type"] == "model":
|
| 860 |
add_verbose({"tag": "chat",
|
| 861 |
"data": f"model[{e['round']}]: {e['text'][:120]}"})
|
| 862 |
+
# In contemplate mode, surface non-empty thoughts
|
| 863 |
+
if CONTEMPLATE and e.get("text", "").strip():
|
| 864 |
with _chat_lock:
|
| 865 |
_chat_messages.append({"role": "phox",
|
| 866 |
"text": f"[thought #{e['round']}] {e['text'][:200]}"})
|