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:
@@ -21,7 +21,13 @@ def main() -> int:
|
||||
ap.add_argument("--melo-device", default="cuda")
|
||||
ap.add_argument("--melo-speed", type=float, default=1.5)
|
||||
ap.add_argument("--melo-language", default="KR")
|
||||
ap.add_argument("--history", default=None, help="conversation history SQLite file; no history without it")
|
||||
ap.add_argument("--brain", action="store_true",
|
||||
help="answer reply requests with the jarvis reply engine (needs --history)")
|
||||
args = ap.parse_args()
|
||||
if args.brain and not args.history:
|
||||
print("--brain needs --history", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
token = os.environ.get("JARVIS_VOICE_TOKEN", "")
|
||||
if not token:
|
||||
@@ -44,10 +50,19 @@ def main() -> int:
|
||||
from .tts_melo import MeloEngine
|
||||
tts = MeloEngine(args.melo_python, args.melo_device, args.melo_speed, args.melo_language)
|
||||
|
||||
history = brain = None
|
||||
if args.history:
|
||||
from jarvis.memory.history import HistoryStore
|
||||
history = HistoryStore(args.history)
|
||||
if args.brain:
|
||||
from .brain import JarvisBrain
|
||||
brain = JarvisBrain()
|
||||
|
||||
async def run() -> None:
|
||||
worker = VoiceWorker(token, transcriber, vad.stream, tts)
|
||||
worker = VoiceWorker(token, transcriber, vad.stream, tts, history=history, brain=brain)
|
||||
server = await worker.serve(args.host, args.port)
|
||||
debug_log(f"voice worker listening on {args.host}:{args.port} tts={'on' if tts else 'off'}",
|
||||
debug_log(f"voice worker listening on {args.host}:{args.port} tts={'on' if tts else 'off'} "
|
||||
f"history={'on' if history else 'off'} brain={'on' if brain else 'off'}",
|
||||
"voice_worker")
|
||||
print(f"READY {args.host}:{args.port}", flush=True)
|
||||
await server.serve_forever()
|
||||
@@ -59,6 +74,8 @@ def main() -> int:
|
||||
finally:
|
||||
if tts:
|
||||
tts.close()
|
||||
if history:
|
||||
history.close()
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user