Start learning free

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

Saying "I Don't Know"

Practice

A model is built to give an answer. When the text you gave it doesn't cover the question, it doesn't stop: it makes an answer up, and it sounds just as sure as when it is right.

The fix is to give the model a way out: say in the prompt what to answer when the information isn't there. Here is the idea for a shop's opening hours:

system = "Opening hours: Monday to Friday, 9 to 17. If the hours don't say, answer exactly: Not sure"

Asked about a holiday, the model now has honest words to use instead of a guess. The word exactly matters: your code can compare the answer with those words using == and do something about it, like passing the question to a person.

In this lesson the Corner Shop's assistant gets the returns policy, which says nothing about gift cards, and a customer asks "Can I return a gift card?". Your program asks twice and must print:

Without the rule: Yes! You can return a gift card within 30 days of delivery, as long as it is unused. The refund goes to the card that paid.
With the rule: I don't know
Passing the question to a person.

Your task: client, MODEL, SYSTEM (the policy) and messages (the question) are already there. Send the question with SYSTEM and print the answer after "Without the rule:". Then make RULE, send the same question with SYSTEM + RULE and print the answer after "With the rule:". When the answer is exactly I don't know, print Passing the question to a person.


Assignment
Follow the Coding Tutorial to ask the question without and with the rule, and to pass it to a person when the model doesn't know.


Hint
The rule is "If the policy doesn't say, answer exactly: I don't know". SYSTEM ends with a space, so SYSTEM + RULE joins cleanly. The reply's text is reply.content[0].text.


STEP 1 OF 8
    Ctrl + Enter to check