Claude 工具调用天气 API 示例|函数调用提示词模板
代码预览
エディタを読み込み中…
P
提示词
Create a single HTML file that demonstrates Claude Tool Use (function calling) by fetching weather data from a public API. Include a UI where the user clicks a button to simulate calling a weather tool, then displays the result as if Claude decided to call the function.
この作例は、会話型AI(Claude など)における Tool Use(関数呼び出し) パターンを示しています。ユーザーがボタンをクリックすると、以下の流れをシミュレーションします。
- Claude が関数
getWeather({city:'Tokyo'})の呼び出しを決定 - ツールが実行される(遅延をシミュレート)
- 結果が Claude に返される(画面表示)
このパターンは、外部APIやデータベースとやりとりするエージェントを構築する際に非常に強力です。
提示词解读
此示例展示了对话式AI(如Claude)中的 Tool Use(函数调用) 模式。当用户点击按钮时,将模拟以下流程:
- Claude 决定调用函数
getWeather({city:'Tokyo'}) - 工具被执行(模拟延迟)
- 结果返回给 Claude(屏幕显示)
此模式在构建与外部API或数据库交互的代理时非常强大。
这个提示对您有帮助吗?
评论
评论将在审核后显示
この記事が役に立ったら投げ銭で応援
Apple Pay / Google Pay / カード (Visa/Mastercard/JCB/Amex) / Link / Alipay / WeChat Pay 対応 · Stripeで安全に決済
開発者が選ぶ最強ツール集
運営者が毎日使っているツール・ガジェット 6選