Practice Lab: Engineer a Structured Extraction Prompt
Learn to design and iterate on structured extraction prompts that produce exactly formatted JSON output. Explore how to handle ambiguous responses, define allowed values, specify confidence levels, and eliminate extra text. This hands-on lab helps you apply validation techniques needed to prepare AI prompts for production.
We'll cover the following...
This chapter covered the process step by step: shaping the prompt, defining the JSON structure, specifying allowed values, adding a fallback, and asking the model to return a confidence estimate. This lab focuses on applying the techniques from the chapter rather than introducing new concepts. It gives you a task and a checklist, and your job is to write the prompt yourself, test it, observe where it produces invalid or inconsistent output, and revise it. This is the same iteration loop engineers use before integrating a prompt into production code.
Ed will be your AI mentor. If you want the answer directly, just type "Ed, give me the answer."
The task
You're building the exact kind of feedback-analysis feature from this chapter's checkpoint. Here's the fixed piece of customer feedback your prompt needs to handle:
"I've emailed support twice about this and haven't heard back in four days. The product itself is fine; I just need someone to actually respond."
Your job is to write a single prompt that gets a model to analyze this feedback and ...