diff --git a/CHANGELOG.md b/CHANGELOG.md index d7c8c5dd8..f75d4eab6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Fixed a `GoogleAssistantContextAggregator` issue where function calls + placeholders where not being updated when then function call result was + different from a string. + - Fixed an issue that would cause `LLMAssistantContextAggregator` to block processing more frames while processing a function call result. diff --git a/src/pipecat/frames/frames.py b/src/pipecat/frames/frames.py index c2a79461f..6452cbfe4 100644 --- a/src/pipecat/frames/frames.py +++ b/src/pipecat/frames/frames.py @@ -384,7 +384,7 @@ class FunctionCallResultFrame(DataFrame): function_name: str tool_call_id: str - arguments: str + arguments: Any result: Any properties: Optional[FunctionCallResultProperties] = None @@ -633,8 +633,8 @@ class FunctionCallInProgressFrame(SystemFrame): function_name: str tool_call_id: str - arguments: str - cancel_on_interruption: bool + arguments: Any + cancel_on_interruption: bool = False @dataclass diff --git a/src/pipecat/services/anthropic.py b/src/pipecat/services/anthropic.py index 6a95d04e2..3e369075a 100644 --- a/src/pipecat/services/anthropic.py +++ b/src/pipecat/services/anthropic.py @@ -725,7 +725,7 @@ class AnthropicAssistantContextAggregator(LLMAssistantContextAggregator): ) async def _update_function_call_result( - self, function_name: str, tool_call_id: str, result: str + self, function_name: str, tool_call_id: str, result: Any ): for message in self._context.messages: if message["role"] == "user": diff --git a/src/pipecat/services/google/google.py b/src/pipecat/services/google/google.py index bfddce46d..554d9cb6b 100644 --- a/src/pipecat/services/google/google.py +++ b/src/pipecat/services/google/google.py @@ -601,23 +601,18 @@ class GoogleAssistantContextAggregator(OpenAIAssistantContextAggregator): async def handle_function_call_result(self, frame: FunctionCallResultFrame): if frame.result: - if not isinstance(frame.result, str): - return - - response = {"response": frame.result} - + await self._update_function_call_result( + frame.function_name, frame.tool_call_id, frame.result + ) + else: + response = {"response": "COMPLETED"} await self._update_function_call_result( frame.function_name, frame.tool_call_id, response ) - else: - await self._update_function_call_result( - frame.function_name, frame.tool_call_id, "COMPLETED" - ) async def handle_function_call_cancel(self, frame: FunctionCallCancelFrame): - await self._update_function_call_result( - frame.function_name, frame.tool_call_id, "CANCELLED" - ) + response = {"response": "CANCELLED"} + await self._update_function_call_result(frame.function_name, frame.tool_call_id, response) async def _update_function_call_result( self, function_name: str, tool_call_id: str, result: Any @@ -626,11 +621,12 @@ class GoogleAssistantContextAggregator(OpenAIAssistantContextAggregator): if message.role == "user": for part in message.parts: if part.function_response and part.function_response.id == tool_call_id: - part.function_response.response = {"response": result} + part.function_response.response = result async def handle_user_image_frame(self, frame: UserImageRawFrame): + response = {"response": "COMPLETED"} await self._update_function_call_result( - frame.request.function_name, frame.request.tool_call_id, "COMPLETED" + frame.request.function_name, frame.request.tool_call_id, response ) self._context.add_image_frame_message( format=frame.format, diff --git a/src/pipecat/services/openai.py b/src/pipecat/services/openai.py index ff7bc0442..cb1edea72 100644 --- a/src/pipecat/services/openai.py +++ b/src/pipecat/services/openai.py @@ -613,7 +613,7 @@ class OpenAIAssistantContextAggregator(LLMAssistantContextAggregator): ) async def _update_function_call_result( - self, function_name: str, tool_call_id: str, result: str + self, function_name: str, tool_call_id: str, result: Any ): for message in self._context.messages: if (