A small Python support-ticket classification example based on the TypeSafe quickstart. It sends a ticket to TypeSafe's System One API and prints three typed judgments: the responsible department, customer frustration, and urgency.
src/main.py evaluates a hardcoded ticket about a failing Stripe integration in a single request:
| Question | Primitive | Result |
|---|---|---|
department |
Choice |
Selects billing, technical, or sales. |
frustration |
Score |
Scores frustration against three ordered levels, from calm to very angry. |
is_urgent |
Noul |
Returns the probability that the message conveys urgency. |
The script loads local configuration with python-dotenv before initializing TypeSafeClient. As described in the official quickstart, the client reads TYPESAFE_API_KEY from the environment and uses jev-latest by default.
- Python 3.14 or newer, as required by this repository's
pyproject.toml. - uv for dependency management.
- A TypeSafe API key from the TypeSafe dashboard.
- Network access to call the TypeSafe API.
Run the following commands from the repository root.
uv sync --lockedThis installs the dependencies recorded in uv.lock, including typesafe-sdk and python-dotenv.
If you do not already have a .env file, copy the template:
cp .env.example .envReplace the placeholder line in .env with your key assignment:
TYPESAFE_API_KEY=your-api-keyKeep your key private. .env is ignored by Git; do not put credentials in source files or documentation.
uv run python src/main.pyThe script prints the department, frustration score, and urgency probability on separate lines. Illustrative output from the official quickstart:
technical
1.0
1.0
Actual results can vary. With the current criteria, the frustration levels are indexed from 0 to 2; urgency ranges from 0 to 1 and is a probability, not a Boolean.
Edit src/main.py to try different inputs:
- Change
ticketto another synthetic support message. - Update the department criteria to match your support teams.
- Adjust the ordered frustration descriptions to reflect your evaluation scale.
- Change the urgency instructions to express the condition you want to evaluate.
The current example reads its input from the source file; it does not accept command-line arguments or interactive input.
src/main.py # Ticket evaluation and printed results
pyproject.toml # Project metadata and dependencies
uv.lock # Locked dependency versions
.python-version # Local Python version selection
.env.example # Environment variable template
AGENTS.md # Contributor guidelines
Check Python syntax without sending an API request:
uv run python -m compileall srcNo automated test suite, formatter, or linter is configured yet. Running the example performs a live API request.
Use the direct script command above: packaging is currently disabled, and the console entry point declared in pyproject.toml references a module that is not present.
See AGENTS.md for contributor guidelines and the TypeSafe Python SDK documentation for further API usage.