diff --git a/src/pipecat/services/google/openai/llm.py b/src/pipecat/services/google/openai/llm.py index da5d1be7a..08a7bcd1b 100644 --- a/src/pipecat/services/google/openai/llm.py +++ b/src/pipecat/services/google/openai/llm.py @@ -199,7 +199,11 @@ class GoogleLLMOpenAIBetaService(OpenAILLMService): # which currently results in an empty function name(''). continue - arguments = json.loads(arguments) + try: + arguments = json.loads(arguments) + except json.JSONDecodeError: + logger.warning(f"{self}: Failed to parse function call arguments: {arguments}") + continue function_calls.append( FunctionCallFromLLM( diff --git a/src/pipecat/services/openai/base_llm.py b/src/pipecat/services/openai/base_llm.py index c06ed3afd..5b444aea1 100644 --- a/src/pipecat/services/openai/base_llm.py +++ b/src/pipecat/services/openai/base_llm.py @@ -567,7 +567,11 @@ class BaseOpenAILLMService(LLMService): for function_name, arguments, tool_id in zip( functions_list, arguments_list, tool_id_list ): - arguments = json.loads(arguments) + try: + arguments = json.loads(arguments) + except json.JSONDecodeError: + logger.warning(f"{self}: Failed to parse function call arguments: {arguments}") + continue function_calls.append( FunctionCallFromLLM( context=context, diff --git a/src/pipecat/services/sambanova/llm.py b/src/pipecat/services/sambanova/llm.py index 20e17b4f2..63f37cb43 100644 --- a/src/pipecat/services/sambanova/llm.py +++ b/src/pipecat/services/sambanova/llm.py @@ -245,7 +245,11 @@ class SambaNovaLLMService(OpenAILLMService): # type: ignore if len(arguments) < 1: continue - arguments = json.loads(arguments) + try: + arguments = json.loads(arguments) + except json.JSONDecodeError: + logger.warning(f"{self}: Failed to parse function call arguments: {arguments}") + continue function_calls.append( FunctionCallFromLLM( context=context,