Back to Portfolio

AI Engineering · Classification and Evaluation

Ticket Triage
Support Classification

A support ticket classifier that starts with rule-based routing, integrates a real AI model, measures accuracy on labeled examples, and keeps a clear line between custom Python code and the API boundary.

RULE-BASED ROUTINGAPI INTEGRATIONPYTHONPYDANTICEVALUATION
Ticket Triage
Project SetupParse Input DataDefine ContractsRule BaselineModel IntegrationEvaluation

Status: Shipped

A Python classifier covering JSON parsing, Pydantic validation, rule-based classification, OpenAI API integration, and evaluation metrics. Includes a test suite and a full reference implementation.

The problem

Support teams face inconsistent ticket routing:

How it works

Read a ticket from JSON. Validate its structure with Pydantic. Route it through one of two classifiers: a rule-based keyword matcher that's fast and free, or an OpenAI API call that's accurate and costs money. Log the prediction with timing and token usage. Then compare both against human labels to see which approach matches reality better.

01JSON file with ticket ID and text
02Python reads and validates ticket
03Choose route: rule-based or API call
04Rule classifier: keyword matching with ranked precedence
05API classifier: OpenAI structured output with schema
06Category + reason returned and logged

What I built

A ten-stage build, from project setup through evaluation and release:

Stage 1

Project setup

Python environment, dependencies, and a runnable entry point.

Stage 2

Ticket ingestion

JSON parsing and structured ticket data.

Stage 3

Input/output contracts

Pydantic models and schema validation at every boundary.

Stage 4

Rule-based baseline

Keyword matching with ranked precedence.

Stage 5

End-to-end pipeline

File I/O, data flow, and logging of each prediction.

Stage 6

API boundary

Requests and responses, tokens, context windows, structured output.

Stage 7

Live model integration

OpenAI SDK, authentication, latency and cost tracking.

Stage 8

Evaluation

Accuracy, confusion matrices, dev vs. holdout sets.

Stage 9

Failure handling

Error handling, retries, and root-cause analysis.

Stage 10

Documentation and release

README, tests, and GitHub publication.

Engineering highlights

The engineering fundamentals behind the classifier:

Python fundamentals

Variables, functions, loops, conditionals, file I/O, and modules.

Data validation

Pydantic schemas enforce structure at boundaries, not just at parse time.

Rules vs. AI

Simple keyword matching compared against a real model on dev and holdout examples.

API integration

Structured requests, response handling, and tracking of token costs and latency.

Evaluation design

Labeled examples, dev/holdout splits, accuracy metrics, error analysis.

Error recovery

Missing files, JSON errors, validation failures, API timeouts, and retries.

Why I built it this way

Many AI demos hide the difference between local logic and an API call. This project keeps that boundary explicit: validate input, build a simple rule-based baseline, then add the model call and measure whether it actually improves results.

The core principle: understanding the real work means defining what success means (evaluation), building something simple that works (rules), knowing when to add complexity (the model call), and measuring whether it helped (accuracy on labeled data).

Tech stack

Python 3.12PydanticJSONOpenAI APIPytestSQLiteGitHub

Explore the code

Browse the source, tests, and reference implementation on GitHub.