why anthropic web search not works?

前情提要 為什麼我明明就有設定要使用web search tool,但查詢出來的結果就是舊的資料呢? 在使用ai api很常會使用到的tool有兩個,一個是web search,另一個是structured outputs,也就是將你的結果變成程式看得懂的格式,讓程式比較好處理 舉例來說,我是一個加密貨幣的平台,我希望可以顯示跟比特幣相關的新聞,讓使用者可以瀏覽.這時我可以使用ai api,請他幫我取得最新10筆有關比特幣的文章,且幫我轉成我指定的json格式,這樣前端就可以直接拿來使用了 node.js example code如下 const message = await anthropic.messages.create({ model: "claude-sonnet-3", max_tokens: 4096, messages: [ { role: "user", content: "give me the latest 10 news about bitcoins", }, ], tools: [ { type: "web_search_20250305", name: "web_search", max_uses: 5, }, { name: "article_format", description: "Provide the article info with url and title", input_schema: { type: "object", properties: { url: { type: "string", description:"The article resource url", }, title: { type: "string", description:"The article title", } }, required: ["url", "title"], }, }, ], tool_choice: { type: "tool", name: "article_format", }, temperature: 0.3, }); 問題說明 我希望ai回傳的資料一定要是特定的資料結構,所以我設定了tool_choice來確article_format他一定會執行,的確資料都有正確被format,但問題來了,結果web search沒反應了,該怎麼辦? ...

October 21, 2025 · 1 min