feat: answer calls in the voice channel through the response policy
- conversation.rs: the loop between the core's events and the rest. Finals go through call detection and the response policy; answers are asked of the brain and spoken from the app's queue, an interruption cancels only that answer, a voice stop silences everything, and missed requests are kept without text (last 100). Tested with a fake voice side. - Core: answer(user, text) adopts a playback request the worker speaks under the same id, cancel(id) stops one request, ask_addressed and ask_rank pass the conversation's questions; new SpeakingStopped, Addressed and Ranked events. - Worker client: reply, addressed and rank messages and their results; a reply with no answer, refused or not sent ends its speech as failed. - Voice worker: addressed and rank messages on their own threads, beside a running reply; a spoken reply cancelled while the brain is answering is not spoken. judges.py holds the two short LLM judgements with the heard text fenced as data; eval evals/test_voice_judges.py. - Specs (conversation, discord core, voice worker), docs/llm_contexts.md and the roadmap updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,14 @@ class Brain(Protocol):
|
||||
"""Blocking; called on a worker thread, one call at a time. ``chat``: the chat backend for
|
||||
the chatChannels tool (voice_worker/chat_bridge.py), or None without registered channels."""
|
||||
|
||||
def addressed(self, user: str, text: str, names: list[str]) -> Optional[bool]:
|
||||
"""Blocking: was ``text`` said to the assistant (called ``names``)? None when it could not tell.
|
||||
Runs on its own thread, also while a reply runs."""
|
||||
|
||||
def rank(self, candidates: list[dict]) -> Optional[list[str]]:
|
||||
"""Blocking: candidate ids (``{"id", "user", "text"}``) most important first; None on failure.
|
||||
Runs on its own thread, also while a reply runs."""
|
||||
|
||||
|
||||
@dataclass
|
||||
class MemorySettings:
|
||||
@@ -150,3 +158,12 @@ class JarvisBrain:
|
||||
debug_log(f"brain reply user={user} ok={bool(answer)} ms={(time.perf_counter() - t0) * 1000:.0f}",
|
||||
"voice_worker")
|
||||
return answer
|
||||
|
||||
def addressed(self, user: str, text: str, names: list[str]) -> Optional[bool]:
|
||||
from .judges import is_addressed
|
||||
return is_addressed(self.cfg.ollama_base_url, self.cfg.ollama_chat_model, names, text)
|
||||
|
||||
def rank(self, candidates: list[dict]) -> Optional[list[str]]:
|
||||
from .judges import rank_requests
|
||||
order = rank_requests(self.cfg.ollama_base_url, self.cfg.ollama_chat_model, [c["text"] for c in candidates])
|
||||
return None if order is None else [candidates[i]["id"] for i in order]
|
||||
|
||||
Reference in New Issue
Block a user