feat(ai-chat-api): implement streaming tool calls with incremental parameter accumulation

- Update API documentation to reflect new streaming tool call mechanism
- Add `message_id` optional field to content and tool_call events
- Change tool_call structure from array to single object with incremental updates
- Add `tool_call_id` to tool_start events for better event correlation
- Implement ToolCallStreamAccumulator class to handle parameter accumulation
- Provide frontend example code for handling streaming tool calls
- Maintain backward compatibility with existing session_id tracking
This commit is contained in:
YueGuobin committed 2026-03-05 22:29:01 +08:00
1 parent 1de7d00db3
commit 511b155da8
4 files changed
+318 -55

No files matched your search

@@ -178,7 +178,7 @@ class ExecuteMultipleDeviceCommands(BaseTool):
List[Dict[str, Any]]: A list of dictionaries containing device names and command outputs.
"""
# Log received input
logger.info("Received input: %s", tool_input)
logger.debug("Received input: %s", tool_input)
# Validate input
device_configs_list, project_id = self._validate_tool_input(tool_input)
@@ -219,7 +219,7 @@ class ExecuteMultipleDeviceCommands(BaseTool):
logger.error("Error executing display on all devices: %s", e)
return [{"error": f"Execution error: {str(e)}"}]
logger.info(
logger.debug(
"Multiple device display execution completed. Results: %s",
json.dumps(results, indent=2, ensure_ascii=False),
)