函数定义示例
函数定义示例
{
"name": "get_weather",
"description": "查询指定城市当前天气",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string", "description": "城市名,如 杭州"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["city"]
}
}| 要点 | description 写使用场景与参数语义;enum 收敛取值;required 标明必填 |
|---|---|
| 与纯提示对比 | Schema 由平台解析与校验,参数错误率低 |
| 兜底 | 仍需处理不调用、调错函数、参数缺失三种情况 |