Recipe: parse_reply, text in, value or problems out
Extractor, type check, enum check in one function. Java uses the course's Json helper; real projects use Jackson.
The recipes of the whole phase in one place: parse a reply into a value or a list of problems, wrap it in one typed-call function that repairs and falls back, and count what happens. Copy these into any LLM feature.
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 6 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write summarise_stats(stats, total) that returns first_try=A repaired=B fallback=C followed by repair rate: B of total as two lines, given a stats dictionary with those keys.
Write safe_label(parse_result, allowed) that takes (value, problems) and returns value['label'] if the value exists and its label is in allowed, otherwise "unknown".
Explain it without notes
Describe the typed-call recipe step by step.
Which counters would you put on a typed call, and what does each tell you?
How would you adapt this phase's recipes to a model that does not offer JSON mode?
Where does validation end and evaluation (Phase 9) begin?
Expected output
case 1: ok label=bug confidence=88
case 2: ok label=feature confidence=71
case 3: confidence: required field is missing
case 4: label: "refund" is not one of billing, bug, feature, unknown | confidence: expected integer, got string
case 5: no complete JSON object in the reply