triage-ticket
This example uses typesafe.ai’s Jev to classify a support ticket. The program fits in one .tsi file: a context statement, a const .ticket contextual binding, and a top-level ask.
Jev answers typed questions about supplied context. The typesafe() provider maps the output type to those questions:
- A string literal union such as
Departmentbecomes a choice question with one option per value. - A number literal union such as
Prioritybecomes a choice question whose answer is decoded back to a number. - A boolean becomes a yes/no question. With the default threshold, the result is
truewhen the probability is greater than 0.5. A value of exactly 0.5 givesfalse. - A flat object such as
Triagegroups its properties into one request, with one question per property. Each property’s JSDoc comment supplies that question’s instructions.
`You triage customer support tickets. Answer every question from the ticket text alone; never guess.`
type Department = "billing" | "shipping" | "account" | "other";type Priority = 1 | 2 | 3;
interface Triage { /** Which team owns this ticket? */ department: Department; /** Does the customer express urgency? */ urgent: boolean; /** 1 = low, 3 = high */ priority: Priority; /** Is the customer asking for a refund? */ refundRequested: boolean;}
// A `.` binding is context: the ask below sees the ticket text.const .ticket = "I was charged twice for order #88 and nobody has answered my emails for a week. I want my money back NOW.";
const triage = ask `triage the support ticket`: Triage;
console.log(JSON.stringify(triage));The provider also supports decision types such as Choice, Scale, and Prob. It does not support unrestricted strings or numbers, arrays, or nested objects. It rejects unsupported types before making a network request and names the unsupported property in the error. For a project that also needs those types, configure a general model as a fallback with fallback([typesafe(), openai("gpt-5-mini")]). See Providers API.
Run it
Section titled “Run it”The example’s config uses model: typesafe(), which makes live requests. Set TYPESAFE_API_KEY=… in .env before running it.
npx nola-lang run src/main.tsi # needs TYPESAFE_API_KEY# offline: edit nola.config.ts to the mockProvider line in its commentScaffold: npm create nola my-app -- --template triage-ticket. You can also select it from the first template menu, before empty. The scaffolder uses the example’s provider and asks you to set its API key.
Source: examples/triage-ticket on GitHub.
Next: Introduction — back to the start.