ComenzarEmpieza gratis

Adding guidelines for the learning advisor chatbot

In the previous exercise, you built a chatbot to recommend textbooks. However, the company has identified a need for an update to ensure more efficient recommendations. You are provided with a base_system_prompt, similar to the one you created previously, and your task is to incorporate behavior_guidelines and response_guidelines. These guidelines will help control the chatbot's behavior and ensure it offers more effective and tailored textbook recommendations to users.

The OpenAI package, and the get_response() function have been pre-loaded for you.

Este ejercicio forma parte del curso

Ingeniería de prompts para ChatGPT para desarrolladores

Ver curso

Instrucciones de ejercicio

  • Define behavior_guidelines for the chatbot that allow it to ask a user about their background, experience, and goals, whenever any of these is not provided in the prompt.
  • Define response_guidelines to tell the chatbot to recommend no more than three textbooks.

Ejercicio interactivo práctico

Pruebe este ejercicio completando este código de muestra.

client = OpenAI(api_key="")

base_system_prompt = "Act as a learning advisor who receives queries from users mentioning their background, experience, and goals, and accordingly provides a response that recommends a tailored learning path of textbooks, including both beginner-level and more advanced options."

# Define behavior guidelines
behavior_guidelines = "____"

# Define response guidelines
response_guidelines = "____"

system_prompt = base_system_prompt + behavior_guidelines + response_guidelines
user_prompt = "Hey, I'm looking for courses on Python and data visualization. What do you recommend?"
response = get_response(system_prompt, user_prompt)
print(response)
Editar y ejecutar código