GifproGifpro

Claude Tool Use Weather API Demo — Prompt & Code Example

CODE PREVIEW

エディタを読み込み中…
P

Prompt

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(関数呼び出し) パターンを示しています。ユーザーがボタンをクリックすると、以下の流れをシミュレーションします。

  1. Claude が関数 getWeather({city:'Tokyo'}) の呼び出しを決定
  2. ツールが実行される(遅延をシミュレート)
  3. 結果が Claude に返される(画面表示)

このパターンは、外部APIやデータベースとやりとりするエージェントを構築する際に非常に強力です。

Prompt Overview

This example demonstrates the Tool Use (Function Calling) pattern in conversational AI (such as Claude). When the user clicks the button, the following flow is simulated:

  1. Claude decides to call the function getWeather({city:'Tokyo'})
  2. The tool is executed (simulated with a delay)
  3. The result is returned to Claude (displayed on screen)

This pattern is extremely powerful when building agents that interact with external APIs or databases.

Was this prompt helpful?

Comments

Comments appear after moderation

この記事が役に立ったら投げ銭で応援

Apple Pay / Google Pay / カード (Visa/Mastercard/JCB/Amex) / Link / Alipay / WeChat Pay 対応 · Stripeで安全に決済

開発者が選ぶ最強ツール集

運営者が毎日使っているツール・ガジェット 6選

見る
Homeヘルプ