From 4b71ebcb925d2652cb7e19ff302fe0c7830642c2 Mon Sep 17 00:00:00 2001 From: rootflo-hardik Date: Fri, 20 Feb 2026 11:51:26 +0530 Subject: [PATCH 1/2] handling unsupported lang switch gracefully --- .../services/language_detection_tool.py | 13 +++++---- .../services/pipecat_service.py | 29 +++++++++++++------ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/wavefront/server/apps/call_processing/call_processing/services/language_detection_tool.py b/wavefront/server/apps/call_processing/call_processing/services/language_detection_tool.py index 87b5b1e..299e2b5 100644 --- a/wavefront/server/apps/call_processing/call_processing/services/language_detection_tool.py +++ b/wavefront/server/apps/call_processing/call_processing/services/language_detection_tool.py @@ -90,15 +90,18 @@ async def detect_and_switch_language(params: FunctionCallParams): # Validation 1: Check if target language is supported if target_language not in supported_languages: - error_msg = ( - f"Language '{target_language}' is not supported. " - f"Supported languages: {', '.join(supported_languages)}" + logger.warning( + f"Language switch attempted for unsupported language: '{target_language}'" ) - logger.warning(error_msg) await params.result_callback( { 'success': False, - 'error': error_msg, + 'error': ( + f"'{target_language}' is not a supported language. " + f"Tell the user you're sorry but this language is not supported, " + f"and that you can only converse in: {', '.join(supported_languages)}. " + f"Do not attempt any language switch." + ), 'current_language': current_language, 'supported_languages': supported_languages, } diff --git a/wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py b/wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py index 2e23f1b..e8b7c0b 100644 --- a/wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py +++ b/wavefront/server/apps/call_processing/call_processing/services/pipecat_service.py @@ -310,9 +310,19 @@ async def run_conversation( initial_language_instruction = LANGUAGE_INSTRUCTIONS.get( default_language, LANGUAGE_INSTRUCTIONS.get('en', 'Respond in English.') ) - system_content = f'{base_system_prompt}\n\n{initial_language_instruction}' - # Store base prompt without language instruction for switching - language_state['original_system_prompt'] = base_system_prompt + language_switching_rules = ( + f'\n\nLANGUAGE SWITCHING RULES:\n' + f'- You support these languages only: {", ".join(supported_languages)}.\n' + f'- Call detect_and_switch_language only when the user clearly intends to choose or change language. ' + f'A single word is a valid choice if it directly answers a language preference question.\n' + f'- Do NOT switch based on a greeting (e.g. "Namaste") or incidental use of another language.\n' + f'- If the user requests a language not in the supported list, apologise and tell them which languages are available. Do not call the switch tool.' + ) + system_content = f'{base_system_prompt}\n\n{initial_language_instruction}{language_switching_rules}' + # Store base prompt without language instruction for switching (rules persist across switches) + language_state['original_system_prompt'] = ( + base_system_prompt + language_switching_rules + ) else: system_content = base_system_prompt @@ -413,12 +423,13 @@ async def run_conversation( language_detection_schema = FunctionSchema( name='detect_and_switch_language', description=( - f"Detect and switch the conversation language. Call this whenever the user " - f"indicates a language preference, including: responding with a language name " - f"(e.g., 'Hindi', 'Spanish', 'English'), requesting a switch (e.g., 'switch to Hindi', " - f"'I want to speak in Spanish'), or selecting a language when asked for their preference. " - f"Even a single word like 'Hindi' or 'Spanish' should trigger this tool if it refers to a language choice. " - f"Supported languages: {', '.join(supported_languages)}. " + f"Switch the conversation language when the user clearly intends to choose or change language. " + f"Use conversational context to judge intent — a single word like 'Hindi' or 'Tamil' counts as an " + f"explicit choice when it directly answers a question about language preference. " + f"Also trigger on explicit requests like 'switch to Hindi', 'speak in Tamil', 'Hindi mein baat karo'. " + f"Do NOT trigger on greetings in another language (e.g. 'Namaste') without a clear intent to switch. " + f"Only switch to languages in the supported list: {', '.join(supported_languages)}. " + f"If the user asks for an unsupported language, do NOT call this tool — inform them directly in the current language. " f"Current language: {language_state['current_language']}." ), properties={ From 577eed710bec99fedb3ad2f15484b8eae334de98 Mon Sep 17 00:00:00 2001 From: rootflo-hardik Date: Fri, 20 Feb 2026 13:48:49 +0530 Subject: [PATCH 2/2] added kannada to deepgram stt list --- .../voice_agents_module/utils/language_validation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/wavefront/server/modules/voice_agents_module/voice_agents_module/utils/language_validation.py b/wavefront/server/modules/voice_agents_module/voice_agents_module/utils/language_validation.py index a5f219c..1929d4c 100644 --- a/wavefront/server/modules/voice_agents_module/voice_agents_module/utils/language_validation.py +++ b/wavefront/server/modules/voice_agents_module/voice_agents_module/utils/language_validation.py @@ -167,6 +167,7 @@ 'id', 'it', 'ja', + 'kn', 'ko', 'lt', 'lv',