說明函式合約
工具包含名稱、清楚的說明,以及參數的 JSON Schema。說明指出何時應選用工具,結構描述則限制引數。
模型只會提出呼叫建議;它本身不會因此取得您的網路、資料庫或檔案存取權。
聊天請求中的函式工具
json
{
"model": "openai/gpt-5.6-sol",
"messages": [{"role": "user", "content": "What is the weather in Tashkent?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Read current weather for a city.",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
"additionalProperties": false
}
}
}],
"tool_choice": "auto"
}在您端執行
- 依允許清單檢查工具名稱。
- 呼叫內部服務前,先依結構描述驗證引數。
- 對工具動作套用您自己的授權、逾時與冪等性控制。
回傳結果
加入一則角色為 tool 的訊息,其中包含 tool_call_id 與精簡的序列化結果,再以相同脈絡繼續對話。
將工具執行失敗與模型失敗分開處理;回傳結構化原因,讓模型能向使用者說明。