P.04LLM Apps
Build a service that classifies incoming support tickets and extracts key fields into a validated JSON schema, ready for routing and reporting.
01
Support queues are full of free-text messages that need to be categorized, prioritized and routed. Rule-based systems break on unusual phrasing, while free-form model output is hard to rely on when downstream code expects specific fields and values.
In this project you build a triage service that turns each ticket into a strictly typed record: category, priority, product area, customer intent and any identifiers mentioned. You define the schema first, validate every response and handle the cases where the model output does not fit.
02
A FastAPI endpoint accepts ticket text, calls a model with a JSON schema derived from Pydantic models and validates the result. Invalid outputs are retried with error feedback, and low-confidence results are flagged for human review.
input · support email
“Hi — I was charged twice for the annual plan on my team account this morning. Can someone refund the duplicate? Order 48213.”
output · TicketTriage
{
"category": "billing",
"priority": "high",
"order_id": "48213",
"needs_human": true
}
Receive ticket
Accept and normalize ticket text and metadata through a typed API endpoint.
Define schema
Describe the output with Pydantic models, enums for categories and priorities, and optional extracted fields.
Generate
Request structured output constrained to the schema, with a short set of labeled examples in the prompt.
Validate & repair
Validate the response, retry once with the validation error on failure and record what went wrong.
Route
Return the typed record, and send low-confidence or invalid results to a review queue.
03
Suggested stack. Equivalent tools are fine; document the choice in your decision record.
04
Stage 01
Design the output schema and label a small dataset of sample tickets, including ambiguous and multi-issue ones.
Stage 02
Implement the classification and extraction call with schema validation and typed responses.
Stage 03
Add retry-with-feedback for invalid output, timeouts and a review queue for uncertain results.
Stage 04
Score the service against your labeled set, adjust the prompt and examples, and record the effect of each change.
05
06
Build the foundations, projects, and habits needed to design more dependable AI applications.