services: mark function calls as completed even the result is None

This commit is contained in:
Aleix Conchillo Flaqué
2025-03-19 14:34:31 -07:00
parent b1d506c137
commit e0c3f6ad83
3 changed files with 25 additions and 19 deletions

View File

@@ -711,12 +711,13 @@ class AnthropicAssistantContextAggregator(LLMAssistantContextAggregator):
)
async def handle_function_call_result(self, frame: FunctionCallResultFrame):
if not frame.result:
return
result = json.dumps(frame.result)
await self._update_function_call_result(frame.function_name, frame.tool_call_id, result)
if frame.result:
result = json.dumps(frame.result)
await self._update_function_call_result(frame.function_name, frame.tool_call_id, result)
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(

View File

@@ -600,15 +600,19 @@ class GoogleAssistantContextAggregator(OpenAIAssistantContextAggregator):
)
async def handle_function_call_result(self, frame: FunctionCallResultFrame):
if not frame.result:
return
if frame.result:
if not isinstance(frame.result, str):
return
if not isinstance(frame.result, str):
return
response = {"response": frame.result}
response = {"response": frame.result}
await self._update_function_call_result(frame.function_name, frame.tool_call_id, response)
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(

View File

@@ -584,12 +584,13 @@ class OpenAIAssistantContextAggregator(LLMAssistantContextAggregator):
)
async def handle_function_call_result(self, frame: FunctionCallResultFrame):
if not frame.result:
return
result = json.dumps(frame.result)
await self._update_function_call_result(frame.function_name, frame.tool_call_id, result)
if frame.result:
result = json.dumps(frame.result)
await self._update_function_call_result(frame.function_name, frame.tool_call_id, result)
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(