DecisionModel
Defined in: src/decisions/decision-model.ts:17
Abstract base for anything that can answer closed questions.
The public ask opens a decision span, validates the question map, delegates
to the subclass _ask, records usage and the answer set as span attributes/events,
and closes the span. Every implementation is traced identically.
Extended by
Section titled “Extended by”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new DecisionModel(): DecisionModel;Returns
Section titled “Returns”DecisionModel
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.
_ask()
Section titled “_ask()”abstract protected _ask<Q>(state, questions): Promise<DecisionResult<Q>>;Defined in: src/decisions/decision-model.ts:69
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>>