Skip to content

Structured extraction

Install the matching release in a Python environment:

Terminal window
python -m pip install cayu

Download structured-output.py, then run:

Terminal window
python structured-output.py

The complete source and explanation sends an invalid first response and a valid repaired response through ScriptedModelProvider. It asserts success, an empty tool-strategy final text, the exact validated output {"invoice_total": 42.5} and repair attempt 2.

This proves runtime schema validation and repair for the fixture. To evaluate a real invoice extractor, replace the scripted provider in your project, use representative synthetic documents, and add assertions for totals, currency and evidence location. A valid schema alone does not prove a correct invoice total.