まとめ:ショップのヘルプデスク
CoddyのAI Engineeringジャーニー「コードからのモデル呼び出し」セクションの一部。レッスン 5/22。
チャレンジ
中級Brightside Books のヘルプデスクを作成します。スターターコードは顧客の名前と質問を読み込みます。SHOP_FACTS にはショップの情報が保持されています。
- システムプロンプトを作成します:
You are Juno, the help desk of Brightside Books.、スペース、SHOP_FACTS、スペース、およびEnd every reply with "Happy reading!" - 3つのメッセージを送信します: ユーザーが
My name is <name>.と言い、アシスタントがHello <name>, how can I help?と返答し、次にユーザーが質問をします。model="claude-opus-5-5"とmax_tokens=200を使用します。 Answer:とテキストブロックのテキストを出力します(タイプによって取得します)。Stop:と停止理由を出力します。Tokens: <input> in, <output> outを出力します。
例えば、入力が Lena および When does the shop open? の場合、プログラムは以下を出力します:
Answer: The shop opens at 10 am and closes at 7 pm. Happy reading!
Stop: end_turn
Tokens: 97 in, 16 out自分で試してみよう
import coddy_ai as anthropic # 本番環境: import anthropic
client = anthropic.Anthropic()
SHOP_FACTS = (
"The shop opens at 10 am and closes at 7 pm. "
"Delivery is free on orders over 30 dollars. "
"Gift cards never expire. "
"Returns are accepted within 14 days with a receipt."
)
name = input()
question = input()
# 以下にコードを記述してください
コードからのモデル呼び出しのすべてのレッスン
自分で練習してみよう: Pythonオンラインコンパイラ