Skip to content

LLMDecisionModel

Defined in: src/decisions/llm-decision-model.ts:68

Adapter that turns any Model into a DecisionModel.

ask is implemented as one direct model call with a dynamically-built StructuredOutputTool and forced toolChoice. Uncertainty is modeled by appending an 'uncertain' option to each permitting question’s enum.

const decision = new LLMDecisionModel({ model: new BedrockModel() })
const result = await decision.ask('The fruit is an apple', {
color: {
question: 'What color is the fruit?',
choices: ['red', 'green', 'blue'],
},
isFruit: {
question: 'Is the thing talked about a fruit?',
choices: 'boolean',
uncertainty: false,
},
})
// result.answers.color is 'red' | 'green' | 'blue' | Uncertain
// result.answers.isFruit is boolean | Uncertain
// (opting out via `uncertainty: false` only removes 'uncertain' from the
// model's enum; the static type still includes Uncertain for safety)
new LLMDecisionModel(options?): LLMDecisionModel;

Defined in: src/decisions/llm-decision-model.ts:78

Create an LLM-backed decision model.

ParameterTypeDescription
optionsLLMDecisionModelOptionsModel and prompt configuration.

LLMDecisionModel

TypeError if options.model is not a Model.

DecisionModel.constructor

ask<Q>(state, questions): Promise<DecisionResult<Q>>;

Defined in: src/decisions/decision-model.ts:29

Ask one or more closed questions over the given state.

Type Parameter
Q extends Record<string, Question<"boolean" | readonly string[]>>
ParameterTypeDescription
stateDecisionInputA plain string, a one-shot content list, or a message history.
questionsQMap of identifier → question. The returned answers object is keyed off this same map and statically narrowed per question.

Promise<DecisionResult<Q>>

A DecisionResult whose answers are statically narrowed from each question’s choices.

Error if questions is empty or contains an invalid question, choices, or uncertainty.

DecisionModel.ask


protected _ask<Q>(state, questions): Promise<DecisionResult<Q>>;

Defined in: src/decisions/llm-decision-model.ts:86

Implementation-specific decision logic. Must return a complete DecisionResult, including metadata.latencyMs sourced from the underlying model provider.

Type Parameter
Q extends Record<string, Question<"boolean" | readonly string[]>>
ParameterType
stateDecisionInput
questionsQ

Promise<DecisionResult<Q>>

DecisionModel._ask