summaryrefslogtreecommitdiffstats
path: root/assistant.py
diff options
context:
space:
mode:
Diffstat (limited to 'assistant.py')
-rw-r--r--assistant.py13
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):