Moderation API
您正在开发一款用于语言学习的教育型聊天机器人。为确保用户不会向您的 API 提交不当内容,您决定在生成回复前,使用 Moderation API 审核用户的提示。
本练习是课程的一部分
使用 OpenAI API 构建 AI 系统
练习说明
- 使用 Moderation API 在
categories中检查用户消息是否包含不当内容。 - 打印响应。
交互式实操练习
通过完成这段示例代码来试试这个练习。
client = OpenAI(api_key="")
message = "Can you show some example sentences in the past tense in French?"
# Use the moderation API
____
# Print the response
____