Skip to content

DecisionsAPIDecisionModel

Defined in: src/decisions/decisions-api-decision-model.ts:38

Decision model backed by decisionapi.net.

const decisions = new DecisionsAPIDecisionModel()
const result = await decisions.ask('A customer needs a refund today.', {
department: { question: 'Which team should handle this?', choices: ['billing', 'support'] },
})
new DecisionsAPIDecisionModel(options?): DecisionsAPIDecisionModel;

Defined in: src/decisions/decisions-api-decision-model.ts:45

ParameterTypeDescription
options?DecisionsAPIDecisionModelOptionsProvider, model, and confidence configuration.

DecisionsAPIDecisionModel

Error if the API key, confidence threshold, or fetch implementation is invalid.

DecisionModel.constructor

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

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

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.
options?AskOptionsPer-call options, such as the request to add the decision’s usage to, or a cancelSignal that aborts the underlying call.

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.

TypeError if options.invocationContext was not created by the SDK.

DecisionModel.ask


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

Defined in: src/decisions/decisions-api-decision-model.ts:58

Implementation-specific decision logic. Must return a complete DecisionResult, including metadata.latencyMs sourced from the underlying model provider. Implementations should forward options.cancelSignal to any cancellable work they start. The request’s invocationContext is not passed: ask records the reported usage itself.

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

Promise<DecisionResult<Q>>

DecisionModel._ask