structured output — making the model return json6 / 9
schemas, pydantic, and validation — making the model return real data
The model returned a response missing the required email field.
In real code, Ticket.model_validate_json(raw) would raise
ValidationError. Here, the assertion on line 8 raises KeyError
before the assertion can run. Fix the script so it prints the string
missing email instead of crashing.
Use if "email" not in data to check first; if missing, print
missing email and exit. Otherwise, continue.
Expected output:
missing email
The break is on lines 8, 9 — but read the whole snippet first.
⌘↵ runs the editor.
Booting Python…
Output
[promptdojo:~]$ _