AI Engineering from Scratch / Stage 2. The model in the product
Plain rules already handle part of the requests, and you know how many: two numbers, coverage and precision, on the same cases where the model will compete later.
Outcome: a baseline report + a decision table
For this lesson you need: evals/own.jsonl and the edge case checklist from lesson 4. At the start of the lesson, in the starter folder:
Came here straight from lesson 0? Run only the first command and skip the second: you don't have a lesson-04 branch, and that's fine. You'll add your own cases in this lesson. You don't need the lesson 4 edge case checklist here either, the list you need is below.
Mac and Linux. The command blocks in lessons 5–9 are written for PowerShell. git and uv run work the same. Swap only five things: Select-String -Path файл -Pattern 'текст' for grep 'текст' файл, New-Item файл for touch файл, Copy-Item a b for cp a b, notepad файл for open -e файл, and $env:НАЗВА for $НАЗВА.
The second command says the file doesn't exist: you have no cases of your own yet, that's fine. The second command says there's no lesson-04 branch: you worked on a different branch. Skip this command, you'll add your own cases in this lesson. git switch says there's no l05 tag: run git fetch --tags and try again. git switch refuses because of unsaved changes: commit them on the lesson 4 branch first (git add -A, then git commit -m "кінець уроку 4").
The l05 tag = l04 plus triage_rules and 30 cases. Your code from lessons 3–4 is replaced with the finished version here; to compare: git diff lesson-04 l05 --stat (without your own lesson 4 branch use git diff l04 l05 --stat).
What changed in the contract. The contract is the CONTRACT.md file in the starter: it lists the fields a request card is made of (a short record about one request: category, order number, amount, tags) and which categories are allowed. The card moves to v2: the category field is filled in by the rules, and when they're unsure it holds None (Python's "nothing"), shown on screen as "don't know". The rules live in triage_rules(text) in support/rules.py. evals/cases.jsonl now has 30 cases with the expected category, ten of them tagged demo. There are eight categories, exactly as in CONTRACT.md: доставка (delivery), повернення (return), обмін (exchange), брак (defect), оплата (payment), акаунт (account), інше (other), невідомо (unknown). A complaint is now just a tag, with no category of its own. git diff --stat l04 l05 shows which files the tag added. If the output takes over the whole screen, press q to exit.
Recall from lesson 3. A 20-line traceback. Where do you start reading it, and why do you give it to the agent whole?
Once an LLM shows up in a project, it's tempting to run everything through it, from parsing a request to the refund amount. Plain code computes the amount in milliseconds and the same way every time, while the model charges you for it and will get a digit wrong sooner or later.