MulaiMulai sekarang secara gratis

Providing context through system prompt

Now you want to use system prompts in order to provide context for the chatbot about MyPersonalDelivery instead of relying on sample conversations. You are provided with a detailed service_description that introduces the services being offered and the benefits of choosing this service. You will then test a user query to see if the model recognizes the context effectively.

The OpenAI package and the service_description string have been pre-loaded for you.

Latihan ini adalah bagian dari kursus

Prompt Engineering with the OpenAI API

Lihat Kursus

Petunjuk latihan

  • Define a system_prompt that defines the purpose of the chatbot including the service_description, and guides it to answer queries in a gentle way.
  • Get the response using the get_response() function, that receives a system and a user prompt as inputs and returns the response as an output.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

client = OpenAI(api_key="")

# Define the system prompt
system_prompt = ____

user_prompt = "What benefits does MyPersonalDelivery offer?"

# Get the response to the user prompt
response = ____

print(response)
Edit dan Jalankan Kode