From 73becbad29bd40cf8d0a5a209d0550718412859d Mon Sep 17 00:00:00 2001 From: chadbailey59 Date: Sat, 12 Oct 2024 17:45:24 -0500 Subject: [PATCH] fixed parallel async function calls bug (#569) --- src/pipecat/services/openai.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pipecat/services/openai.py b/src/pipecat/services/openai.py index 2f98a7e10..6eee6f77f 100644 --- a/src/pipecat/services/openai.py +++ b/src/pipecat/services/openai.py @@ -254,12 +254,11 @@ class BaseOpenAILLMService(LLMService): arguments_list.append(arguments) tool_id_list.append(tool_call_id) - total_items = len(functions_list) for index, (function_name, arguments, tool_id) in enumerate( zip(functions_list, arguments_list, tool_id_list), start=1 ): if self.has_function(function_name): - run_llm = index == total_items + run_llm = False arguments = json.loads(arguments) await self.call_function( context=context, @@ -550,7 +549,8 @@ class OpenAIAssistantContextAggregator(LLMAssistantContextAggregator): "tool_call_id": frame.tool_call_id, } ) - run_llm = frame.run_llm + # Only run the LLM if there are no more function calls in progress. + run_llm = not bool(self._function_calls_in_progress) else: self._context.add_message({"role": "assistant", "content": aggregation})