CourseAI Engineering: The Complete Course · Module 7: LLM Engineering · part 57 of 105
Part 57 · Module 7: LLM Engineering

Lab: Build BrightCart's answer engine end to end

18 min read·13 Oct 2026
Module 7 · Lab · About 75 minutes · Needs: lessons 1 to 6 of this module (prompts, structured output, reliability, context, cost, security)

What you are building

ANSWER(TICKET, KEY): ONE TICKET IN, ONE CHECKED REPLY OUT ticket + key cache? prompt v1 model call fallback validate sanitise log cost CheckedReply, logged a hit skips straight to the log
The finished piece: your code (blue) wraps the model (amber) on both sides, checks (green) stand between the model and the customer, and a cache hit skips the model entirely.

Six lessons built six parts of the answer engine. This lab joins them into one function, answer(ticket, key), which later modules rebuild in smaller forms. A ticket goes in; a checked Reply comes out. On the way: a versioned prompt that knows today's date, outside text marked as data, a schema with one repair, a Groq-to-Gemini fallback with a canned last resort, an idempotency cache, an output sanitiser and a cost log. You finish by running eight tickets, two of them Sam's attacks, and printing a scorecard Priya, Marta and Sam can each read.

The rest of this course is yours to keep

This course is bought on its own, once, and stays readable afterwards, including the parts added to it later.