A decision
Questions with fixed options about something, and an answer to each. On a decision model each answer comes with its probability.
pnpm add @niscorp/signal zodA decision model
typesafe is a provider of another kind: its model writes no text. It reads a state and questions, and returns a probability for each option. It needs no SDK.
import { createSignal } from '@niscorp/signal';
const decider = createSignal('typesafe');The questions
A choice has options, each with a sentence saying when it applies. A noul is a yes or no, answered as the probability of yes. A score is a level on a scale you describe.
The questions are the schema: an answer that names an option you did not give fails the call.
const questions = {
wants: {
type: 'choice',
instructions: 'What does the member want?',
criteria: { seats: 'Seats for a night', refund: 'Money back', other: 'Anything else' },
},
urgent: { type: 'noul', instructions: 'Does it need an answer today?' },
} as const;The decision
state is what the questions are about: a string, an object or a list. Each answer is typed from its question, so wants.choice is one of your three options.
calibrated says whether the numbers are there. A chat provider can answer the same call, and then it is false and you get the choices alone.
const result = await decider.decide({ state: 'Two for The Tempest on Saturday, please.', questions });
console.log(result.decisions.wants.choice, result.decisions.urgent.answer);
if (result.calibrated) {
console.log(result.decisions.wants.probabilities, result.decisions.urgent.noul);
}Run it.
This file asks a decision model, so it is not run on this site. It prints the choice and the yes or no, for instance seats false, and then the probability of each option and of yes.
TYPESAFE_API_KEY=your-key npx tsx decide.mts