feat(voice_worker): record history from the app and answer reply requests with the brain
Worker (voice_worker.spec.md "History and brain"): - --history <file> keeps the conversation history store; --brain hosts the jarvis reply engine (JarvisBrain, settings point ollama_base_url at /v1). - voice_join / voice_leave / member_join / member_leave keep presence; the session end closes it. Non-empty finals are stored under the speaker's name in the current voice channel. - chat_message / chat_edit / chat_delete keep registered chat channels. - reply builds the asker's scoped history context, runs the brain on a thread (one at a time), answers reply_text, stores a voice answer, and with speak=true says it under the same id. memory settings in hello and memory_config. brain_unavailable without --brain. App (discord_core.spec.md "History reporting"): - WorkerClient sends the new messages; the core reports the voice channel and its heard members after a join, a move and every worker reconnect, member joins and leaves, voice_leave when a session ends, and every message of a readable registered channel (its own too, with `to` on replies), edits and deletes. - live_discord runs the worker with --history and checks the store at the end: 8 finals under the speaker's name, the edited chat message only, Jarvis's own messages, 5 presence intervals, none left open (passed, 107.8 s). Eval: history recall gains a chat-record case and fails a reply that reads a record stamp out (field run with qwen2.5:7b did once in four). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,13 +8,15 @@ model actually uses a matching earlier record to answer a question about a
|
||||
past conversation, and that the block is what makes the difference (the same
|
||||
question without the block cannot be answered from anything else).
|
||||
|
||||
The fact is a day of the week that the model cannot guess, so the check is a
|
||||
The reply must answer in its own words, not read a record line out (TTS would
|
||||
speak the stamp). The fact is a day of the week that the model cannot guess, so the check is a
|
||||
plain substring on the reply (in either language, since the reply language is a
|
||||
setting).
|
||||
|
||||
Run: EVAL_JUDGE_MODEL=qwen2.5:7b python -m pytest evals/test_history_context_recall.py -v
|
||||
"""
|
||||
|
||||
import re
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
@@ -41,8 +43,21 @@ CASES = [
|
||||
"matches": ["[2026-11-08 20:10] Alice: the cat's vet appointment is on Thursday at 3pm"],
|
||||
"expect": ["thursday"],
|
||||
},
|
||||
{
|
||||
# Field run 2026-11-11 (qwen2.5:7b through the voice worker): a chat channel record from
|
||||
# someone else, asked about by the user. The reply opened by reading the record line out,
|
||||
# stamp and all, which TTS would speak.
|
||||
"id": "korean-chat-record",
|
||||
"query": "이번 주 모임 언제 어디라고 했지?",
|
||||
"recent": [],
|
||||
"matches": ["[2026-11-11 11:55] 민수: 이번 주 모임은 토요일 오후 네 시에 강남역이야"],
|
||||
"expect": ["토요일", "saturday"],
|
||||
},
|
||||
]
|
||||
|
||||
# A record line read out: any "[YYYY-MM-DD HH:MM]" stamp in the reply.
|
||||
_STAMP = re.compile(r"\[\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}\]")
|
||||
|
||||
|
||||
def _run(mock_config, eval_db, eval_dialogue_memory, query, history):
|
||||
from helpers import JUDGE_BASE_URL, JUDGE_MODEL
|
||||
@@ -77,6 +92,9 @@ class TestHistoryContextRecall:
|
||||
assert any(e in lowered for e in case["expect"]), (
|
||||
f"[{case['id']}] reply did not use the earlier record: {response!r}"
|
||||
)
|
||||
assert not _STAMP.search(response or ""), (
|
||||
f"[{case['id']}] reply read a record line out instead of answering: {response!r}"
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize("case", CASES, ids=[c["id"] for c in CASES])
|
||||
def test_without_the_block_the_fact_is_unknown(self, mock_config, eval_db, eval_dialogue_memory, case):
|
||||
|
||||
Reference in New Issue
Block a user