LLM Ticket Triage Service
A small service that classifies and summarises support tickets with an LLM inside a token budget, with retries, a mock-backed test suite and a measured prompt comparison. It proves you can integrate an LLM API reliably before adding retrieval.
- Intro
- 6 milestones · 38 steps in all
- Quizzes on 7 skills
- Self-paced
Start with M1: Labelled ticket set. Build it one step at a time; your progress is saved as you go.
What you will build
- Build a labelled set of synthetic support tickets and validate it against a schema.
- Call models through one provider-neutral client with timeouts, bounded jittered retries and per-call usage logging, tested offline against a mock.
- Compare two prompt versions on the labelled set and analyse why they fail.
- Measure a local open-weight model and a hosted model for accuracy, latency and cost per 1,000 tickets.
- Serve a token-budgeted endpoint that returns validated JSON, and document setup, design choices and cost in a README.
Tools and ground rules
- Python 3.12 with Pydantic, httpx, FastAPI, tiktoken and pytest; Ollama serving a small open-weight model (default qwen2.5:1.5b, Apache-2.0).
- Synthetic tickets, or data under a licence that allows your use; no real personal data in the repository.
- No paid provider or API key is needed for any milestone except the optional hosted row in M4; the mock provider can stand in for a model throughout.
- No hard-coded secrets: keys are read from the environment (an untracked .env), and the Git history is scanned before submission.
Getting started
Follow the milestones in order. Each one is a short list of steps you work through and mark done, and ends with a quiz on each skill it used: passing a quiz is what counts as evidence for that skill.
From brief to evidence
- Milestone 1 · M1
Labelled ticket set
At least 50 synthetic or licensed tickets, cleaned and validated against a schema, each with a category label.
Done when: The validation script passes on the committed data and a reviewer spot-checks 10 labels.
7 steps
- Create the repository and environment
- Write the labelling rules before the data
- Describe a valid ticket with Pydantic
- Write ticket templates, including hard ones
- Generate, clean and de-duplicate
- Validate the file on disk and report every problem
- Test the rules, spot-check 10 labels and commit
- Milestone 2 · M2
LLM client with failure handling
Provider-neutral client with timeouts, jittered retries and per-call usage logging.
Done when: Automated tests against a mock provider simulate 429, 500 and timeout responses and pass without network access.
7 steps
- Define a provider-neutral interface
- Write a mock provider
- Add jittered backoff and a usage log
- Wrap any provider in a retrying client
- Make the network unreachable in tests
- Simulate 429, 500 and timeouts
- Test the waits and the log, then commit
- Milestone 3 · M3
Prompt versions compared
Two prompt versions with accuracy on the labelled set and three analysed failures.
Done when: A reviewer re-runs the comparison script and obtains the reported accuracy within run-to-run variance.
7 steps
- Serve a small open-weight model locally
- Talk to any OpenAI-compatible server
- Test the HTTP mapping without a server
- Choose the model with one setting
- Write two prompt versions
- Compare both prompts on every ticket
- Analyse three failures and keep the better prompt
- Milestone 4 · M4
Hosted versus local model
The better prompt run on the labelled set against one hosted model and one locally served open-weight model through the same client, with accuracy, latency and estimated cost per 1,000 tickets.
Done when: A reviewer switches models with one configuration change and reproduces both result rows.
6 steps
- Document every setting in .env.example
- Read prices from the configuration
- Measure accuracy, latency and cost per 1,000 tickets
- Benchmark the local model
- Benchmark a hosted model (optional)
- Write up the comparison and commit
- Milestone 5 · M5
Budgeted HTTP endpoint
Endpoint that returns category and summary as validated JSON and rejects inputs over the token budget.
Done when: Automated tests check the response schema and the over-budget rejection; a secret scan finds no API key in the repository.
6 steps
- Allocate a token budget
- Triage one ticket, with one retry for bad JSON
- Expose POST /triage
- Test the response schema and the over-budget rejection
- Run the service and call it with curl
- Commit, then scan the history for secrets
- Milestone 6 · M6
README with cost estimate
README covering setup, design choices and estimated cost per 1,000 tickets.
Done when: A second person runs the service from the README; the cost estimate is consistent with logged token usage.
5 steps
- Summarise the usage log
- Check your estimates against the logged counts
- Write the README: setup, use and cost
- Explain the design choices and limits
- Run it from a fresh clone, then hand it over
A project worth finishing
Finish all 6 milestones and pass their quizzes to demonstrate the skills this project uses. Next in the series: Retrieval Benchmark for a Docs Corpus.