開始使用免費開始

產生量身打造的回應

既然客戶詢問已通過審核,現在要產生一個量身打造的回應。

為了讓聊天機器人更精準地回應,你會提供相關脈絡。這裡有兩份文件可用:

  • faqs:常見客戶問題與解答
  • content_overview:相關學習路徑,含描述與連結

修正後的逐字稿仍可透過 corrected_text 取得。

本練習屬於課程

使用 OpenAI API 的多模態系統

檢視課程

練習說明

  • 完成提示詞,清楚給出指示,並將 faqscontent_overview 兩份文件納入脈絡。
  • 使用 gpt-4o-mini 模型產生回應,並將 instruction_prompt 作為 system 訊息、corrected_text 作為 user 訊息送出。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

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)
編輯並執行程式碼