1. 学ぶ
  2. /
  3. コース
  4. /
  5. Developing AI Systems with the OpenAI API

Connected

演習

Adding guardrails

You are developing a chatbot that provides advice for tourists visiting Rome. You've been asked to keep the topics limited to only covering questions about food and drink, attractions, history and things to do around the city. For any other topic, the chatbot should apologize and say 'Apologies, but I am not allowed to discuss this topic.'.

指示

100 XP
  • Write a user message with the user_request given, and a system message to tell the model to assess the question first: if it is allowed, provide a reply, otherwise provide the message: 'Apologies, but I am not allowed to discuss this topic.'.
  • Print the response.