GoogleAssistantContextAggregator: function call result should be a JSON object
This commit is contained in:
@@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Fixed
|
### 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
|
- Fixed an issue that would cause `LLMAssistantContextAggregator` to block
|
||||||
processing more frames while processing a function call result.
|
processing more frames while processing a function call result.
|
||||||
|
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ class FunctionCallResultFrame(DataFrame):
|
|||||||
|
|
||||||
function_name: str
|
function_name: str
|
||||||
tool_call_id: str
|
tool_call_id: str
|
||||||
arguments: str
|
arguments: Any
|
||||||
result: Any
|
result: Any
|
||||||
properties: Optional[FunctionCallResultProperties] = None
|
properties: Optional[FunctionCallResultProperties] = None
|
||||||
|
|
||||||
@@ -633,8 +633,8 @@ class FunctionCallInProgressFrame(SystemFrame):
|
|||||||
|
|
||||||
function_name: str
|
function_name: str
|
||||||
tool_call_id: str
|
tool_call_id: str
|
||||||
arguments: str
|
arguments: Any
|
||||||
cancel_on_interruption: bool
|
cancel_on_interruption: bool = False
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
@@ -725,7 +725,7 @@ class AnthropicAssistantContextAggregator(LLMAssistantContextAggregator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def _update_function_call_result(
|
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:
|
for message in self._context.messages:
|
||||||
if message["role"] == "user":
|
if message["role"] == "user":
|
||||||
|
|||||||
@@ -601,23 +601,18 @@ class GoogleAssistantContextAggregator(OpenAIAssistantContextAggregator):
|
|||||||
|
|
||||||
async def handle_function_call_result(self, frame: FunctionCallResultFrame):
|
async def handle_function_call_result(self, frame: FunctionCallResultFrame):
|
||||||
if frame.result:
|
if frame.result:
|
||||||
if not isinstance(frame.result, str):
|
await self._update_function_call_result(
|
||||||
return
|
frame.function_name, frame.tool_call_id, frame.result
|
||||||
|
)
|
||||||
response = {"response": frame.result}
|
else:
|
||||||
|
response = {"response": "COMPLETED"}
|
||||||
await self._update_function_call_result(
|
await self._update_function_call_result(
|
||||||
frame.function_name, frame.tool_call_id, response
|
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):
|
async def handle_function_call_cancel(self, frame: FunctionCallCancelFrame):
|
||||||
await self._update_function_call_result(
|
response = {"response": "CANCELLED"}
|
||||||
frame.function_name, frame.tool_call_id, "CANCELLED"
|
await self._update_function_call_result(frame.function_name, frame.tool_call_id, response)
|
||||||
)
|
|
||||||
|
|
||||||
async def _update_function_call_result(
|
async def _update_function_call_result(
|
||||||
self, function_name: str, tool_call_id: str, result: Any
|
self, function_name: str, tool_call_id: str, result: Any
|
||||||
@@ -626,11 +621,12 @@ class GoogleAssistantContextAggregator(OpenAIAssistantContextAggregator):
|
|||||||
if message.role == "user":
|
if message.role == "user":
|
||||||
for part in message.parts:
|
for part in message.parts:
|
||||||
if part.function_response and part.function_response.id == tool_call_id:
|
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):
|
async def handle_user_image_frame(self, frame: UserImageRawFrame):
|
||||||
|
response = {"response": "COMPLETED"}
|
||||||
await self._update_function_call_result(
|
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(
|
self._context.add_image_frame_message(
|
||||||
format=frame.format,
|
format=frame.format,
|
||||||
|
|||||||
@@ -613,7 +613,7 @@ class OpenAIAssistantContextAggregator(LLMAssistantContextAggregator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def _update_function_call_result(
|
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:
|
for message in self._context.messages:
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user