Recipe: the typed call (parse, validate, repair, fallback)
The fake model replies from a script. A real client would send each error back as part of the next request.
Every recipe from the course, one per phase, with the topic where you built it, a symptom lookup, and four runnable recipes that are used together most often: typed calls, resilient calls, a safe tool runner and an evaluation gate.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 5 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write pick_label(raw, allowed) that returns the one allowed label found (ignoring case) in the model's raw reply, or other when none or more than one is found. Print results for Billing, I think shipping or billing and no idea with the allowed labels billing and shipping.
Write tally(events) that counts outcomes such as ok, retry and fallback in a list, and print the counts sorted by name.
Explain it without notes
If you had one day to make a prototype production-ready, which recipes would you add first, and in what order?
How do you decide whether a new recipe or guard is worth adding?
A quality drop is reported a week after a prompt change. Which recipes would have caught it, and how?
Expected output
t1: billing after 1 attempt(s)
t2: shipping after 2 attempt(s)
error: label must be one of billing, other, shipping
t3: other after 3 attempt(s) (fallback)
error: no JSON object found
error: label must be one of billing, other, shipping
error: no JSON object found