ニーズに合わせた応答を生成する
コンテンツモデレーションを通過したので、次はニーズに合わせた応答を生成します。
チャットボットが正確に回答できるよう、関連するコンテキストを渡します。以下の 2 つのドキュメントが利用できます。
faqs: よくある質問と回答content_overview: 関連するトラック(説明とリンクを含む)
修正済みの書き起こしは corrected_text として引き続き利用できます。
この演習はコースの一部です
OpenAI APIで学ぶマルチモーダルシステム
演習の手順
- 明確な指示を与え、コンテキストとして
faqsとcontent_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)