开始使用免费开始使用

生成定制化回复

既然客户咨询已经通过内容审核,现在该生成一条定制化回复了。

为帮助聊天机器人更准确地作答,您将提供相关上下文。有两份文档可用:

  • 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)
编辑并运行代码