Let Code Do the Math
Part of the AI Decisions section of Coddy's AI Prompts journey. Lesson 17 of 22.
The text can be data: an order or a form, sent as JSON. It is tempting to let the AI apply your rules to it. Small models are poor at comparing numbers, though. For this order:
{"order": 1044, "days_since_delivery": 5, "item_used": true, "reason": "does not like the colour"}Is days_since_delivery more than 30?
yes █████████████████░░░ 83%
no ███░░░░░░░░░░░░░░░░░ 17%5 is not more than 30, yet the AI leans to yes. Your code gets it right every time: days_since_delivery > 30.
So split the work. Code checks numbers, dates and true or false fields. The AI reads what code cannot: the words a person typed, like the customer's note.
Challenge
MediumA returns app asks the AI late, a number comparison its code already does. It should read the customer's note instead.
Remove late and add a choice reason that reads the note, with the options damaged, wrong_item and changed_mind, each described.
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in AI Decisions
1Let the AI Decide
From Reply to DecisionDescribe Your OptionsOptions That Don't OverlapLeave a Way OutReading the AnswerRecap: Let the AI Decide4Decisions in an App
Several Questions at OnceLet Code Do the MathDecide, Then WriteRecap: Decisions in an App