diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-26 08:18:58 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-26 08:18:58 +0200 |
| commit | f44feb7d6ed65fde69f29e92c8f673fc8a641674 (patch) | |
| tree | 70b8a5f342a2a984f5b7b7a28f61f51272474f4f | |
| parent | 0c834c81365ee6e2259c4a93009ac241941aecdb (diff) | |
| download | desktop-assistant-f44feb7d6ed65fde69f29e92c8f673fc8a641674.tar.gz desktop-assistant-f44feb7d6ed65fde69f29e92c8f673fc8a641674.zip | |
Fix issues found testing the tools live
- The model has no clock and invented a 2025 start date for the
calendar; the system prompt now carries the current date and time.
- It also derived a wrong weekday from a date; agenda.py prints the
weekday itself.
- An announcement ran straight into the answer; a 0.6 s pause follows it.
- The calendar days hint asks for 30 or more when looking for the next
event.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| -rw-r--r-- | assistant.py | 10 | ||||
| -rwxr-xr-x | examples/tools/agenda.py | 11 | ||||
| -rw-r--r-- | examples/tools/calendar.toml | 2 |
3 files changed, 16 insertions, 7 deletions
diff --git a/assistant.py b/assistant.py index 16e6133..84f0dd8 100644 --- a/assistant.py +++ b/assistant.py @@ -275,6 +275,10 @@ def speaker(q): play.wait() play = None continue + if isinstance(item, float): # seconds of silence + if play: + play.stdin.write(bytes(int(sr * item) * 2)) + continue text, lang = item audio, sr = k.create(text, voice=voices[lang], lang=KLANG[lang]) if play is None: @@ -333,7 +337,9 @@ def reply(history, q): log(f"you ({lang}, {time.perf_counter() - t:.2f}s): {text}") history.append({"role": "user", "content": text}) # ponytail: last 20 messages, summarise if long sessions need memory - msgs = [{"role": "system", "content": CFG["system"]}] + history[-20:] + # 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:] t, said, voice, announced = time.perf_counter(), [], lang, False def say(s): @@ -364,6 +370,8 @@ def reply(history, q): if phrase: # The question's language: the reply has no text yet to follow. q.put((phrase, lang)) + # A beat after it: straight into the answer sounds rushed. + q.put(0.6) announced = True for c in calls.values(): result = run_tool(TOOLS, c["name"], c["arguments"]) diff --git a/examples/tools/agenda.py b/examples/tools/agenda.py index 44bc34b..6c5bfca 100755 --- a/examples/tools/agenda.py +++ b/examples/tools/agenda.py @@ -77,6 +77,7 @@ def when(line): def agenda(d, start, days): # ponytail: naive local times, so a recurring event in a zone other than # ours drifts by an hour across DST; multi-day events show on day one only. + # The weekday is printed because the model gets it wrong from a date. lo = dt.datetime.fromisoformat(start) hi = lo + dt.timedelta(days=days) evs = [] @@ -106,7 +107,7 @@ def agenda(d, start, days): occ = [first] if lo <= first < hi else [] summary = e.get("SUMMARY", "SUMMARY:(no title)").split(":", 1)[1] summary = summary.replace("\\,", ",").replace("\\;", ";").replace("\\n", " ") - out += [(t, f"{t:%Y-%m-%d} {'all day' if allday else f'{t:%H:%M}'} {summary}") + out += [(t, f"{t:%A %Y-%m-%d} {'all day' if allday else f'{t:%H:%M}'} {summary}") for t in occ] return [line for _, line in sorted(out)] @@ -140,11 +141,11 @@ def test(): with open(os.path.join(d, "cal", name), "w", newline="") as f: f.write(text) assert agenda(d, "2026-09-01", 30) == [ - "2026-09-01 18:00 Gym", "2026-09-16 19:00 Gym moved", - "2026-09-22 18:00 Gym", "2026-09-29 18:00 Gym"], agenda(d, "2026-09-01", 30) - assert agenda(d, "2026-03-10", 5) == ["2026-03-12 all day Birthday"] + "Tuesday 2026-09-01 18:00 Gym", "Wednesday 2026-09-16 19:00 Gym moved", + "Tuesday 2026-09-22 18:00 Gym", "Tuesday 2026-09-29 18:00 Gym"], agenda(d, "2026-09-01", 30) + assert agenda(d, "2026-03-10", 5) == ["Thursday 2026-03-12 all day Birthday"] assert agenda(d, "2026-10-01", 1) == [ - "2026-10-01 10:00 Dentist, checkup", "2026-10-01 18:00 Call"] # 16Z = 18 local + "Thursday 2026-10-01 10:00 Dentist, checkup", "Thursday 2026-10-01 18:00 Call"] # 16Z = 18 local assert agenda(d, "2026-10-02", 1) == [] print("ok") diff --git a/examples/tools/calendar.toml b/examples/tools/calendar.toml index 75e4898..50b578c 100644 --- a/examples/tools/calendar.toml +++ b/examples/tools/calendar.toml @@ -8,4 +8,4 @@ description = "First day, YYYY-MM-DD. Empty for today." [params.days] type = "integer" -description = "How many days, 1 for a single day. Empty for 1." +description = "How many days, 1 for a single day, 30 or more for the next event. Empty for 1." |
