Skip to content

feat: LLM-triggered switch_language tool for multilingual conversations#533

Draft
san0808 wants to merge 1 commit intomasterfrom
feat/llm-switch-language-tool
Draft

feat: LLM-triggered switch_language tool for multilingual conversations#533
san0808 wants to merge 1 commit intomasterfrom
feat/llm-switch-language-tool

Conversation

@san0808
Copy link
Contributor

@san0808 san0808 commented Mar 3, 2026

Summary

  • Adds switch_language as a built-in LLM tool (same pattern as transfer_call) that lets the LLM switch ASR/TTS languages mid-conversation via function calling
  • Adds TranscriberPool and SynthesizerPool — thin wrappers that hold multiple transcriber/synthesizer instances and expose a switch(label) method for instant language switching
  • Multilingual setup paths in __setup_transcriber / __setup_synthesizer that read a multilingual config block and build pools
  • Tool is auto-injected into api_tools when pools are active (with enum constraint listing available languages) — no manual config needed
  • Pre-call filler message is suppressed for switch_language so the switch is seamless
  • On tool call: pools switch → tool result appended to history → LLM re-invoked so it continues in the new language

Flow

LLM emits switch_language(language="hi")
  → TaskManager.__execute_function_call intercepts it
    → calls self.switch_language("hi") → pools switch active member
    → appends tool result to conversation history
    → re-invokes LLM (which now responds in Hindi)

Files changed

  • bolna/constants.pySWITCH_LANGUAGE_TOOL_DEFINITION schema
  • bolna/agent_manager/task_manager.py__inject_switch_language_tool(), handler in __execute_function_call, switch_language() method, multilingual pool setup paths
  • bolna/helpers/utils.py — suppress pre-call filler for switch_language
  • bolna/transcriber/transcriber_pool.py — new TranscriberPool class
  • bolna/synthesizer/synthesizer_pool.py — new SynthesizerPool class
  • bolna/transcriber/__init__.py, bolna/synthesizer/__init__.py — pool exports

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant