Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 12.9 — Playbook: Service Skeleton
LLM Engineering · Example 2 of 2

The pre-launch review as code

Nine production basics checked against a configuration. Run something like this in CI.

A small service skeleton you can copy: authenticate, enforce a tenant quota, build a budgeted context, call the model, stream events, store the exchange and log the outcome, plus a pre-launch review that checks the production basics.

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.

01

Write sse(event) that turns a Python dict into one line data: <compact json> (use json.dumps with separators=(",", ":")) followed by a blank line, and print the encoding of {"delta": "Hi "} with repr.

02

Write join_events(lines) that takes the SSE lines of the skeleton (strings starting with data: ) and returns the text made from all delta events joined together, ignoring other events.

Explain it without notes

01

Walk through the steps of a request in the skeleton and say why they are in that order.

02

What belongs in the final event of a stream?

03

What would you add before taking this skeleton to production?

The pre-launch review as code
Sign in to run this example in your browser.

Expected output

ready: 9 of 9 pass
draft: 6 of 9 pass
  fix: every query is scoped by tenant
  fix: model calls have a timeout and a fallback
  fix: readiness and liveness endpoints exist