Start learning free

LESSON 24 OF 129 · AI ENGINEERING: PROMPTS THAT HOLD UP

The Assistant's System Prompt

Practice

A support assistant's system prompt has five jobs. It says who the model is (role), what it knows (facts), what it must and must not do (rules), how it should sound (tone), and what to do when it has no answer (when unsure). Leave one part out and the model fills the gap by itself, often badly.

Build the prompt from parts: keep each part in its own string that starts with its label, and join the strings. Then the program can check its own prompt with in. Here is the idea on a library's help desk:

ROLE = "Role: you are a library's help desk. "
FACTS = "Facts: a book is lent for 14 days. "
PROMPT = ROLE + FACTS

print("Facts:" in PROMPT)   # True
print("Tone:" in PROMPT)    # False: nobody wrote that part yet

In this lesson the Corner Shop's assistant starts with only a role and facts. It answers three questions, and each bad answer points to a missing part: a made-up discount code (no rules), long and stiff sentences (no tone), invented umbrellas (no way out when unsure). When all five parts are in, your program prints:

Role: True
Facts: True
Rules: True
Tone: True
When unsure: True
Q: How long does delivery take?
A: It takes 3 to 5 days and costs $4. Happy shopping!
Q: Can I get a discount?
A: Sorry, I can't give discounts. Is there anything else I can help with?
Q: Do you sell umbrellas?
A: I don't know, sorry! Our team can tell you: write to help@cornershop.example.

Your task: the client, the questions and the first two parts are already there. Add a loop that checks the five labels, send each question with SYSTEM and print the answers, then write the three missing parts, RULES, TONE and UNSURE, and join each one into SYSTEM.


Assignment
Follow the Coding Tutorial to check the prompt, ask the three questions and complete the system prompt one part at a time.


Hint
Each part is a string that starts with its label and ends with a space, so the parts don't run together. A new part needs two lines: the variable, and its + line inside the parentheses of SYSTEM.


STEP 1 OF 12
    Ctrl + Enter to check