支持工具调用的对话请求(with Tools)
POST
http://localhost:11434/api/chat
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'http://localhost:11434/api/chat' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "你好,你是谁?"
}
],
"stream": false,
"tools": [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "获取当前天气",
"parameters": {
"type": "object",
"properties": {
"property1": {
"type": "string",
"description": "城市名称",
"enum": [
"北京",
"上海",
"广州"
]
},
"property2": {
"type": "string",
"description": "城市名称",
"enum": [
"北京",
"上海",
"广州"
]
}
},
"required": [
"location"
]
}
}
}
]
}'
响应示例响应示例
{
"model": "llama3.2",
"created_at": "2024-07-22T20:33:28.123648Z",
"message": {
"role": "assistant",
"content": "",
"tool_calls": [
{
"function": {
"name": "get_current_weather",
"arguments": {
"format": "celsius",
"location": "Paris, FR"
}
}
}
]
},
"done_reason": "stop",
"done": true,
"total_duration": 885095291,
"load_duration": 3753500,
"prompt_eval_count": 122,
"prompt_eval_duration": 328493000,
"eval_count": 33,
"eval_duration": 552222000
}
请求参数
Body 参数application/json
返回响应
修改于 2025-03-27 09:15:13