TypeSafeDecisionModel
Defined in: src/decisions/typesafe-decision-model.ts:37
Decision model backed by TypeSafe’s hosted Jev API.
Example
Section titled “Example”const decisions = new TypeSafeDecisionModel()const result = await decisions.ask('A customer needs a refund today.', { urgent: { question: 'Is this urgent?', choices: 'boolean' },})Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new TypeSafeDecisionModel(options?): TypeSafeDecisionModel;Defined in: src/decisions/typesafe-decision-model.ts:44
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options? | TypeSafeDecisionModelOptions | Provider, model, and confidence configuration. |
Returns
Section titled “Returns”TypeSafeDecisionModel
Throws
Section titled “Throws”Error if the API key, confidence threshold, or fetch implementation is invalid.
Overrides
Section titled “Overrides”Methods
Section titled “Methods”ask<Q>( state, questions, options?): Promise<DecisionResult<Q>>;Defined in: src/decisions/decision-model.ts:34
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. |
options? | AskOptions | Per-call options, such as the request to add the decision’s usage to. |
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.
Throws
Section titled “Throws”TypeError if options.invocationContext was not created by the SDK.
Inherited from
Section titled “Inherited from”_ask()
Section titled “_ask()”protected _ask<Q>(state, questions): Promise<DecisionResult<Q>>;Defined in: src/decisions/typesafe-decision-model.ts:57
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>>