說明用戶端函式
如範例所示,在 tools 陣列中將 `web_search` 作為標準函式工具傳送。模型只會請求呼叫;您的應用程式會透過獲准來源執行搜尋。
執行後,以含相符 tool_call_id 的 role `tool` 訊息將標準化結果回傳給模型。模型文字不能取代來源;請保留 URL、標題、日期與脈絡。
由用戶端執行的網路搜尋函式
json
{
"model": "openai/gpt-5.6-sol",
"messages": [{"role": "user", "content": "Find current primary sources for this topic."}],
"tools": [{
"type": "function",
"function": {
"name": "web_search",
"description": "Search permitted sources for current information.",
"parameters": {
"type": "object",
"properties": {"query": {"type": "string"}},
"required": ["query"],
"additionalProperties": false
}
}
}]
}可靠的答案
- 執行搜尋前先驗證函式名稱與 query 引數。
- 若工作流程需要驗證,請在相關主張附近向使用者顯示連結。
- 若組織政策要求,請在產品端限制網域或任務。
成本與日誌
在函式執行器中,將搜尋支出與模型 token 用量分開追蹤。
取得部分輸出後,請勿自動重複搜尋;應先確認哪些來源已送達,以及使用者已看到哪些內容。