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
____