工具调用理论基础
Function Calling
Function Calling 就是让大模型把用户的话转换成“要调用哪个函数、传什么参数”的结构化指令。
Function Call 需要先定义函数,向 LLM 描述函数的用途、输入参数格式(JSON Schema):
{
"name": "get_current_weather",
"description": "获取指定城市的天气",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "城市名称"
},
"unit": {
"enum": ["celsius", "fahrenheit"]
}
},
"required": ["city"]
}
}
2026/4/27大约 12 分钟
