8.2 工具定义与设计
8.2.1 优秀工具定义的特征
8.2.2 工具定义结构
{
"name": "search_products",
"description": "在产品数据库中搜索商品",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "搜索关键词"
},
"category": {
"type": "string",
"enum": ["electronics", "clothing", "books"],
"description": "产品类别"
},
"price_max": {
"type": "number",
"description": "最高价格限制"
},
"sort_by": {
"type": "string",
"enum": ["price", "rating", "newest"],
"default": "rating",
"description": "排序方式"
}
},
"required": ["query"]
}
}8.2.3 设计原则
原则一:单一职责
原则二:参数设计清晰
原则三:提供足够的描述
原则四:合理使用枚举
8.2.4 常见工具类型
类型
示例
特点
8.2.5 工具数量的权衡
8.2.6 工具分组策略
8.2.7 工具文档最佳实践
8.2.8 工具测试
8.2.9 上下文感知的工具设计
命名空间(Namespacing)
响应格式优化
模式
Token 消耗
适用场景
工具使用示例(Tool Use Examples)
Last updated
