aboutsummaryrefslogtreecommitdiffstats
path: root/assistant.py
diff options
context:
space:
mode:
Diffstat (limited to 'assistant.py')
-rw-r--r--assistant.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/assistant.py b/assistant.py
index db527a5..777ceba 100644
--- a/assistant.py
+++ b/assistant.py
@@ -548,7 +548,9 @@ def reply(mine, text):
with lock:
if turn == mine:
cur["pending"] = None
- emit({"type": "error", "message": str(e) or type(e).__name__})
+ # turn: this error ended the reply. Command errors carry no
+ # turn and must not end a reply another client is watching.
+ emit({"type": "error", "message": str(e) or type(e).__name__, "turn": True})
emit({"type": "state", "state": "idle"})
@@ -824,7 +826,8 @@ def test():
script["replies"] = [['data: {"error": {"message": "context full"}}\n\n']]
CFG["thinking"] = False
send(type="ask", text="too much")
- assert until("error")[-1]["message"] == "context full"
+ e = until("error")[-1]
+ assert e["message"] == "context full" and e["turn"] is True
assert script["body"]["chat_template_kwargs"]["enable_thinking"] is False
CFG["thinking"] = True
# Stop mid-stream: no token after done, nothing saved.
@@ -865,7 +868,8 @@ def test():
({"type": "ask", "text": None}, "bad text"),
({"type": "search", "q": 3}, "bad query")):
send(**cmd)
- assert until("error")[-1]["message"] == why, cmd
+ e = until("error")[-1]
+ assert e["message"] == why and "turn" not in e, cmd # a command error
assert cur["id"] == conv # none of them touched the conversation
real, DB = DB, None # every query now raises
send(type="list")
@@ -887,7 +891,7 @@ def test():
# llama-server down: an error, not a dead thread.
CFG["llm"] = "http://127.0.0.1:9/v1"
send(type="ask", text="anyone?")
- assert until("error")[-1]["type"] == "error"
+ assert until("error")[-1]["turn"] is True
assert until("state")[-1]["state"] == "idle" and cur["pending"] is None
# A second client gets hello with the conversation so far.
c2 = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)