From e98dd70ff9dbf3bacfd639c0d03aeb37011ed50b Mon Sep 17 00:00:00 2001 From: rootflo-hardik Date: Mon, 2 Mar 2026 17:21:07 +0530 Subject: [PATCH 1/2] lang instruction to beginning of prompt --- .../call_processing/services/language_detection_tool.py | 2 +- .../call_processing/call_processing/services/pipecat_service.py | 2 +- 2 files changed, 2 insertions(+), 2 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 299e2b57..41ac2087 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 @@ -150,7 +150,7 @@ async def detect_and_switch_language(params: FunctionCallParams): return # Append new language instruction to clean base prompt - updated_content = f'{base_prompt}\n\n{language_instruction}' + updated_content = f'{language_instruction}\n\n{base_prompt}' updated_system_message = { 'role': 'system', 'content': updated_content, 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 069d8871..b1b6798b 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 @@ -321,7 +321,7 @@ async def run_conversation( 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}' + system_content = f'{initial_language_instruction}\n\n{base_system_prompt}{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 From c1b80f1f93b7d1b6b8cf3d3fc70431b2f113f8f5 Mon Sep 17 00:00:00 2001 From: rootflo-hardik Date: Tue, 3 Mar 2026 12:08:35 +0530 Subject: [PATCH 2/2] pipecat - support openai compatible llms --- .../call_processing/services/llm_service.py | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/wavefront/server/apps/call_processing/call_processing/services/llm_service.py b/wavefront/server/apps/call_processing/call_processing/services/llm_service.py index 3bd00fd9..199111ff 100644 --- a/wavefront/server/apps/call_processing/call_processing/services/llm_service.py +++ b/wavefront/server/apps/call_processing/call_processing/services/llm_service.py @@ -50,7 +50,13 @@ def create_llm_service(llm_config: Dict[str, Any]): logger.info(f'Creating LLM service: {llm_type} / {model}') if llm_type == 'openai': - return LLMServiceFactory._create_openai_llm(api_key, model, parameters) + base_url = llm_config.get('base_url') + if not base_url or base_url == 'https://api.openai.com/v1': + return LLMServiceFactory._create_openai_llm(api_key, model, parameters) + else: + return LLMServiceFactory._create_openai_compatible_llm( + api_key, model, parameters, base_url + ) elif llm_type == 'azure_openai': base_url = llm_config.get('base_url') if not base_url: @@ -97,6 +103,36 @@ def _create_openai_llm(api_key: str, model: str, parameters: Dict[str, Any]): return OpenAILLMService(api_key=api_key, model=model, params=input_params) + @staticmethod + def _create_openai_compatible_llm( + api_key: str, model: str, parameters: Dict[str, Any], base_url: str + ): + """Create a BaseOpenAILLMService for OpenAI-compatible endpoints""" + params_dict = {} + + if 'temperature' in parameters: + params_dict['temperature'] = parameters['temperature'] + if 'max_completion_tokens' in parameters: + params_dict['max_completion_tokens'] = parameters['max_completion_tokens'] + if 'top_p' in parameters: + params_dict['top_p'] = parameters['top_p'] + if 'frequency_penalty' in parameters: + params_dict['frequency_penalty'] = parameters['frequency_penalty'] + if 'presence_penalty' in parameters: + params_dict['presence_penalty'] = parameters['presence_penalty'] + if 'seed' in parameters: + params_dict['seed'] = parameters['seed'] + + input_params = BaseOpenAILLMService.InputParams(**params_dict) + + logger.info( + f"OpenAI-compatible LLM config: model={model}, base_url={base_url}, temp={params_dict.get('temperature', 'default')}" + ) + + return BaseOpenAILLMService( + api_key=api_key, model=model, base_url=base_url, params=input_params + ) + @staticmethod def _create_google_llm(api_key: str, model: str, parameters: Dict[str, Any]): """Create Google LLM service"""