The AI cookbook.
Read a full workflow from its purpose to its limits. These local Python references show the engineering decisions around a model. There are no exercises, accounts, or model keys required.
← Return to the reading courseA model call with an honest boundary
Wrap a fallible generator in a small response contract and distinguish transport success from task success.
Model call contract · Structured output · ArchitectureA structured routing decision
Parse JSON, validate a small schema, and keep invalid model output away from downstream actions.
Sampling and structure · Structured workflows · EvaluationA tiny grounded answer pipeline
Search approved passages, construct a labelled context, and decline when evidence is absent.
Retrieval foundations · Search and ranking · Prompt designAn evaluation report that explains failure
Score retrieval and answer behavior by slice instead of hiding everything in one average.
Evaluation data · Judging generated answers · Search and rankingA bounded tool-using workflow
Let a planner request read-only tools while software enforces permissions and a step limit.
Tools and agents · Security and trust · Conversation stateA prompt injection boundary
Keep retrieved content as quoted evidence and filter allowed documents before prompt construction.
Prompt design · Retrieval foundations · Security and trustMeasure cost and cache with context
Estimate request cost and construct a cache key that includes prompt, document, and permission versions.
Inference economics · Serving architecture · MonitoringA release gate and monitoring loop
Turn task, permission, holdout, fallback, and live status into an explicit release decision.
Use-case contract · Serving architecture · Monitoring and feedback