3.3 处理工具调用结果
3.3.1 识别工具调用请求
停止原因 (Stop Reason)
内容块结构 (The Content Block)
{
"stop_reason": "tool_use",
"content": [
{
"type": "text",
"text": "好的,我来查询北京和上海的天气。"
},
{
"type": "tool_use",
"id": "toolu_01...",
"name": "get_weather",
"input": {"city": "Beijing"}
},
{
"type": "tool_use",
"id": "toolu_02...",
"name": "get_weather",
"input": {"city": "Shanghai"}
}
]
}3.3.2 并行工具执行 (Parallel Tool Use)
执行策略
3.3.3 构造工具结果 (Tool Results)
基础文本结果
错误处理 (is_error)
is_error)多模态结果 (返回图片)
3.3.4 多轮对话的历史维护
3.3.5 完整代码范例 (Python)
最后更新于
