始める無料で始める

ニーズに合わせた応答を生成する

コンテンツモデレーションを通過したので、次はニーズに合わせた応答を生成します。

チャットボットが正確に回答できるよう、関連するコンテキストを渡します。以下の 2 つのドキュメントが利用できます。

  • faqs: よくある質問と回答
  • content_overview: 関連するトラック(説明とリンクを含む)

修正済みの書き起こしは corrected_text として引き続き利用できます。

この演習はコースの一部です

OpenAI APIで学ぶマルチモーダルシステム

コースを見る

演習の手順

  • 明確な指示を与え、コンテキストとして faqscontent_overview のドキュメントを含めるプロンプトを完成させてください。
  • gpt-4o-mini モデルを使って応答を生成し、システムメッセージに instruction_prompt、ユーザーメッセージに corrected_text を送信します。

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

client = OpenAI(api_key="")

# Complete the prompt
instruction_prompt = f"""
#### Role
You are a professional AI support assistant for DataCamp. You help with:
- Sales (pricing, plans, billing)
- Content (courses, recommendations, feedback)
- Marketing (partnerships, collaborations)

#### How to Respond
1. Use the FAQs: ____
2. Use the content overview: ____
3. Respond clearly and concisely in up to 3 paragraphs.
4. If unsure, direct the user to [email protected].
"""

# Generate response
response = ____

chatbot_reply = response.choices[0].message.content
print(chatbot_reply)
コードを編集して実行