feat(voice_worker): the v2 brain answers in Korean unless asked for another language

The brain passes default_language (worker --reply-language, default Korean) to
the reply engine; unlike the output_language lock it gives way when the user
explicitly asks for a language. Tools get the ko code (--tool-language).

Eval evals/test_reply_language_default.py (Qwen3.6 on Strata): 6/6, English
questions answered in Korean, an explicit English request in English, and the
control without the default answers English in English.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 10:34:12 +09:00
parent cefe9b9253
commit 7623d6d002
9 changed files with 170 additions and 25 deletions

View File

@@ -118,16 +118,19 @@ class JarvisBrain:
tool carry-over follows the person who asked.
"""
def __init__(self, language: Optional[str] = None):
def __init__(self, language: Optional[str] = "ko", reply_language: Optional[str] = "Korean"):
from jarvis.config import load_settings
from jarvis.memory.db import Database
# v1's tts_engine names the v1 desktop voice (English-only Piper by default), which makes the
# engine lock replies to English. v2 speaks through the worker's TTS and chat answers are
# not spoken, so the brain answers in the asker's language (an OUTPUT_LANGUAGE lock still wins).
# not spoken; the brain answers in ``reply_language`` (an OUTPUT_LANGUAGE lock still wins).
self.cfg = dataclasses.replace(load_settings(), tts_engine="melo")
self.db = Database(self.cfg.db_path, self.cfg.sqlite_vss_path)
# ``language``: the ISO code tools get (e.g. the Wikipedia host); ``reply_language``: replies
# come in it unless the asker explicitly asks for another language (None: the asker's).
self.language = language
self.reply_language = reply_language
self._memories: dict = {}
self._lock = threading.Lock()
debug_log(f"brain ready: llm={self.cfg.ollama_base_url} model={self.cfg.ollama_chat_model}", "voice_worker")
@@ -156,7 +159,8 @@ class JarvisBrain:
turn_state.set_chat(chat)
try:
return run_reply_engine(self.db, self.cfg, None, text, self._memory(user),
language=self.language, history=history, legacy_memory=False)
language=self.language, history=history, legacy_memory=False,
default_language=self.reply_language)
finally:
turn_state.reset()