diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-26 13:44:24 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-26 13:44:24 +0200 |
| commit | e372786e5d3c34133ebe18d7df8e1f9dac8329ca (patch) | |
| tree | f5426a3dc193c0505e0e19d31fc07adb6864e53d /assistant.py | |
| parent | f5948fc5a6ec7ca91c6f454ca119a453a0ecb1a8 (diff) | |
| download | desktop-assistant-e372786e5d3c34133ebe18d7df8e1f9dac8329ca.tar.gz desktop-assistant-e372786e5d3c34133ebe18d7df8e1f9dac8329ca.zip | |
Stamp the time on each question, ask for digits, add a temperature key
With the clock only in the system prompt, "what time is it?" asked again
an hour later copied the old answer from history. The current question
now carries the date and time too; history stays unstamped, because
stamping every message made the model drop tool arguments (the finance
account filter went from 6/6 to 0/6).
Gemma garbles numbers it spells out in Italian ("trent settler"), 3 in
10 time answers. The default system prompt asks for digits, which
Kokoro reads correctly: 20/20 clean.
temperature in config.toml is sent with every request; unset keeps the
llama-server preset's, which other clients share.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'assistant.py')
| -rw-r--r-- | assistant.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/assistant.py b/assistant.py index 8ccc6ff..bf6049a 100644 --- a/assistant.py +++ b/assistant.py @@ -51,10 +51,12 @@ DEFAULTS = { "system": ("You are a voice assistant. Your replies are spoken aloud, so answer " "briefly in plain sentences: no markdown, no lists, no emoji. " "Reply in the language the user speaks, Italian or English. " + "Write numbers, times and dates in digits, never spelled out. " "Facts about the user's computer, devices, accounts, mail, calendar " "or money come only from a tool: call one, and if none can tell, " "say you do not know. Never guess them."), "tool_rounds": 3, + "temperature": None, # None: the llama-server preset's "whisper": {"model": "/data/voice-models/whisper/ggml-large-v3-turbo-q5_0.bin", "device": 0, "port": 8182}, "kokoro": {"model": "/data/voice-models/kokoro/kokoro-v1.0.onnx", @@ -374,6 +376,8 @@ def ask(messages, calls, tools=None): "chat_template_kwargs": {"enable_thinking": False}} if tools: body["tools"] = tools + if CFG["temperature"] is not None: + body["temperature"] = CFG["temperature"] req = urllib.request.Request(CFG["llm"] + "/chat/completions", json.dumps(body).encode(), {"Content-Type": "application/json"}) with urllib.request.urlopen(req) as r: @@ -542,8 +546,13 @@ def reply(history, q, mine): question = {"role": "user", "content": text} # ponytail: last 20 messages, summarise if long sessions need memory # The model has no clock: without the date it makes one up for tools. - now = time.strftime("It is %A %d %B %Y, %H:%M.") - msgs = [{"role": "system", "content": f"{CFG['system']} {now}"}] + history[-20:] + [question] + # Also stamped on the question itself, which history does not keep: with + # the time only in the system prompt, "what time is it?" asked again an + # hour later copied the old answer from history. Stamping every message + # in history fixed that but lost tool arguments (account filter 0/6). + now = time.strftime("%A %d %B %Y, %H:%M") + msgs = ([{"role": "system", "content": f"{CFG['system']} It is {now}."}] + history[-20:] + + [{"role": "user", "content": f"[{now}] {text}"}]) t, said, voice, announced = time.perf_counter(), [], lang, False def say(s): |
