Skip to content

M5 solution

The expected, fully-commented artifacts for M5's lab. Peek only after you've tried the lab.

File What it is
ab_compare.py The A/B harness, sends one input through a vague and an engineered system prompt and prints both, so the difference is visible.
rewrite.py The engineered tool levelled up: a clear system role + a few-shot example + structured JSON output parsed into a Python dict.

Run it

With your venv active and your M4 .env (key) in the folder:

python ab_compare.py     # see vague vs engineered
python rewrite.py        # few-shot + JSON; paste a blunt message when asked

How this was verified

Verified on Python 3 with anthropic + python-dotenv, with the live model call mocked (no key or billed call used): - both files compile; - ab_compare.py routes each call to the right system prompt and prints both outputs; - rewrite.py's JSON handling was exercised on three reply shapes, clean JSON (parsed), **``json-fenced** JSON (fences stripped, parsed), and **malformed** text (raisesJSONDecodeError, caught by themain` guard with a helpful message).

The only thing a real key adds is the actual model wording, that's the learner's live run, and the one item flagged for a human pilot.