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.
Example
Section titled “Example”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)Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new LLMDecisionModel(options?): LLMDecisionModel;Defined in: src/decisions/llm-decision-model.ts:78
Create an LLM-backed decision model.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options | LLMDecisionModelOptions | Model and prompt configuration. |
Returns
Section titled “Returns”LLMDecisionModel
Throws
Section titled “Throws”TypeError if options.model is not a Model.
Overrides
Section titled “Overrides”Methods
Section titled “Methods”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 Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Q extends Record<string, Question<"boolean" | readonly string[]>> |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
state | DecisionInput | A plain string, a one-shot content list, or a message history. |
questions | Q | Map of identifier → question. The returned answers object is keyed off this same map and statically narrowed per question. |
Returns
Section titled “Returns”Promise<DecisionResult<Q>>
A DecisionResult whose answers are statically narrowed from
each question’s choices.
Throws
Section titled “Throws”Error if questions is empty or contains an invalid question,
choices, or uncertainty.
Inherited from
Section titled “Inherited from”_ask()
Section titled “_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 Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Q extends Record<string, Question<"boolean" | readonly string[]>> |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
state | DecisionInput |
questions | Q |
Returns
Section titled “Returns”Promise<DecisionResult<Q>>