Building, Testing, and Operating LLM Guardrails in Production
Every guard is real code. The book's companion app, recommendation-system-rag, is a working multi-tenant RAG assistant (FastAPI + LangGraph + Ollama + pgvector + Next.js). Every guard in the book is a module in backend/app/guardrails/ — not pseudocode, not a toy snippet. You can trigger every guard from the chat UI, watch it fire in live screenshots reproduced in the book, and query its verdict from the guard_audit table.
Fully local, zero API keys. The entire stack — generation (llama3.1), guard classification (llama3.2:1b), embeddings (nomic-embed-text), vector search (pgvector) — runs on your machine through Ollama and Postgres. You can red-team it as hard as you like without a bill or a data-sharing worry.
Interview-honest. Each chapter closes with seven interview-grade questions and full answers — 84 in total — drawn from what senior AI-engineering interviews actually ask about safety, reliability, and production operations.
Proven, not claimed. The book treats "it works" as a claim requiring evidence: unit tests, an adversarial corpus with CI gates (block-rate floor and false-positive ceiling), latency benchmarks per layer, end-to-end smoke tests, and Playwright screenshots of every guard blocking a real attack in the running UI.