extract-person
Typed extraction of a nested object — the “hello world” of Nola. The JSON Schema is derived from the Person interface at compile time and the extraction is one typed expression: no runtime type-to-schema library, no re-declared model class. src/format.ts is plain TypeScript, value-imported from the .tsi with the standard NodeNext ./format.js specifier — existing TS code mixes into a nola module with no extra setup.
import { normalizePerson } from "./format.js";
export interface Person { name: string; age: number; employer: string; job: string;}
export infer function extractPerson(.message: string) { const person = ask ..`the person described in the text`<Person>; return normalizePerson(person);}// Plain TypeScript, imported from person.tsi with the standard NodeNext// `./format.js` specifier — mixing existing TS code into a nola module// needs no special setup.import type { Person } from "./person.tsi";
export function normalizePerson(person: Person): Person { return { ...person, name: person.name.trim(), employer: person.employer.trim() };}Run it
Section titled “Run it”npx nola run src/main.ts # mock provider (deterministic)# real provider: edit nola.config.ts to openai({ model: "gpt-5-mini" }) (needs OPENAI_API_KEY)Prints {"name":"Alice Smith","age":32,"employer":"Acme Corp","job":"staff engineer"}.
Scaffold: npm create nola my-app — the starter template is this example (without the format.ts helper).
Source: examples/extract-person on GitHub.
Next: extract-resume