MediaPipe Task that performs semantic decision making.
Signature:
export declare class DecisionMaker extends TaskRunner
Extends: TaskRunner
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| contextUsage | number | Estimated token usage of the active schema and most recent evaluation. | |
| contextWindow | number | Maximum token window supported by the active model/session. |
Methods
| Method | Modifiers | Description |
|---|---|---|
| classify(input, options) | Evaluates input against the session-bound ClassifierSchema configured via DecisionMakerOptions or setSchema(). |
|
| close() | Closes the DecisionMaker and releases the native engine and model memory. | |
| createFromModelBuffer(wasmFileset, modelAssetBuffer, backendType, maxNumTokens) | static |
Initializes the Wasm runtime and creates a new Decision from model buffer. |
| createFromModelPath(wasmFileset, modelAssetPath, backendType, maxNumTokens) | static |
Initializes the Wasm runtime and creates a new Decision from model asset path. |
| createFromOptions(wasmFileset, options) | static |
Initializes the Wasm runtime and creates a new Decision based on options. |
| evaluate(input, schema, options) | Evaluates a multi-question ClassifierSchema against input and returns a unified ClassifierResult record keyed by question id (compatible with window.Classifier). |
|
| evaluateBatch(inputs, schema, options) | Evaluates a multi-question ClassifierSchema across a batch of inputs. |
|
| evaluateBoolean(text, question) | Evaluates a Boolean Predicate condition against input text or multimodal context. | |
| evaluateBooleanBatch(texts, question, sharedPrefix) | Evaluates a Boolean Predicate condition against a batch of input texts (with an optional sharedPrefix for candidate batching). | |
| evaluateChoice(text, question) | Evaluates a Categorical Choice against input text or multimodal context. | |
| evaluateChoiceBatch(texts, question, sharedPrefix) | Evaluates a Categorical Choice against a batch of input texts (with an optional sharedPrefix for candidate batching). | |
| evaluateScore(text, question) | Evaluates an Ordinal Score rubric against input text or multimodal context. | |
| evaluateScoreBatch(texts, question, sharedPrefix) | Evaluates an Ordinal Score rubric against a batch of input texts (with an optional sharedPrefix for candidate batching). | |
| measureContextUsage(input, options) | Estimates the total token usage for evaluating input (and optional per-call context) against the session schema. |
|
| prewarm(schema) | Prewarms the underlying engine KV/prefix cache for the given schema. | |
| setOptions(options) | Sets the options for the DecisionMaker and initializes the underlying engine. Options cannot be updated once the engine has been created. | |
| setSchema(schema) | Updates the session-bound ClassifierSchema used by classify(). |
DecisionMaker.contextUsage
Estimated token usage of the active schema and most recent evaluation.
Signature:
get contextUsage(): number;
DecisionMaker.contextWindow
Maximum token window supported by the active model/session.
Signature:
get contextWindow(): number;
DecisionMaker.classify()
Evaluates input against the session-bound ClassifierSchema configured via DecisionMakerOptions or setSchema().
Signature:
classify(input: string | DecisionContextInput, options?: ClassifierEvaluateOptions): Promise<ClassifierResult>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| input | string | DecisionContextInput | The input text or multimodal context to be evaluated. |
| options | ClassifierEvaluateOptions | Optional per-call evaluation options. The results keyed by question id. |
Returns:
Promise<ClassifierResult>
DecisionMaker.close()
Closes the DecisionMaker and releases the native engine and model memory.
Signature:
close(): void;
Returns:
void
DecisionMaker.createFromModelBuffer()
Initializes the Wasm runtime and creates a new Decision from model buffer.
Signature:
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array | ReadableStreamDefaultReader, backendType?: number, maxNumTokens?: number): Promise<DecisionMaker>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| modelAssetBuffer | Uint8Array | ReadableStreamDefaultReader | An array or a stream containing a binary representation of the model. |
| backendType | number | The backend type (0=AUTO, 1=ENCODER, 2=DIRECT_LOGIT, 3=EMBEDDING). |
| maxNumTokens | number | The maximum number of tokens in prompt context. |
Returns:
Promise<DecisionMaker>
DecisionMaker.createFromModelPath()
Initializes the Wasm runtime and creates a new Decision from model asset path.
Signature:
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string, backendType?: number, maxNumTokens?: number): Promise<DecisionMaker>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| modelAssetPath | string | The path to the model asset. |
| backendType | number | The backend type (0=AUTO, 1=ENCODER, 2=DIRECT_LOGIT, 3=EMBEDDING). |
| maxNumTokens | number | The maximum number of tokens in prompt context. |
Returns:
Promise<DecisionMaker>
DecisionMaker.createFromOptions()
Initializes the Wasm runtime and creates a new Decision based on options.
Signature:
static createFromOptions(wasmFileset: WasmFileset, options: DecisionMakerOptions): Promise<DecisionMaker>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| options | DecisionMakerOptions | The options for the DecisionMaker. Note that either a path to the model or the model itself needs to be provided (via baseOptions). |
Returns:
Promise<DecisionMaker>
DecisionMaker.evaluate()
Evaluates a multi-question ClassifierSchema against input and returns a unified ClassifierResult record keyed by question id (compatible with window.Classifier).
Signature:
evaluate(input: string | DecisionContextInput, schema: ClassifierSchema, options?: ClassifierEvaluateOptions): Promise<ClassifierResult>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| input | string | DecisionContextInput | The input text or multimodal context to be evaluated. |
| schema | ClassifierSchema | The schema containing the questions to evaluate. |
| options | ClassifierEvaluateOptions | Optional per-call evaluation options. The results keyed by question id. |
Returns:
Promise<ClassifierResult>
DecisionMaker.evaluateBatch()
Evaluates a multi-question ClassifierSchema across a batch of inputs.
Signature:
evaluateBatch(inputs: Array<string | DecisionContextInput>, schema: ClassifierSchema, options?: ClassifierEvaluateOptions): Promise<ClassifierResult[]>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| inputs | Array<string | DecisionContextInput> | The input texts or multimodal contexts to be evaluated. |
| schema | ClassifierSchema | The schema containing the questions to evaluate. |
| options | ClassifierEvaluateOptions | Optional per-call evaluation options. One result per input, in the same order as inputs. |
Returns:
Promise<ClassifierResult[]>
DecisionMaker.evaluateBoolean()
Evaluates a Boolean Predicate condition against input text or multimodal context.
Signature:
evaluateBoolean(text: string | DecisionContextInput, question: BooleanQuestion): Promise<BooleanResult>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| text | string | DecisionContextInput | The input text or multimodal context to be evaluated. |
| question | BooleanQuestion | The boolean question to evaluate. The boolean evaluation result. |
Returns:
Promise<BooleanResult>
DecisionMaker.evaluateBooleanBatch()
Evaluates a Boolean Predicate condition against a batch of input texts (with an optional sharedPrefix for candidate batching).
Signature:
evaluateBooleanBatch(texts: string[], question: BooleanQuestion, sharedPrefix?: string): Promise<BooleanResult[]>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| texts | string[] | The input texts to be evaluated. |
| question | BooleanQuestion | The boolean question to evaluate. |
| sharedPrefix | string | An optional prefix shared by all inputs. One result per input text. |
Returns:
Promise<BooleanResult[]>
DecisionMaker.evaluateChoice()
Evaluates a Categorical Choice against input text or multimodal context.
Signature:
evaluateChoice(text: string | DecisionContextInput, question: ChoiceQuestion): Promise<ChoiceResult>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| text | string | DecisionContextInput | The input text or multimodal context to be evaluated. |
| question | ChoiceQuestion | The choice question to evaluate. The choice evaluation result. |
Returns:
Promise<ChoiceResult>
DecisionMaker.evaluateChoiceBatch()
Evaluates a Categorical Choice against a batch of input texts (with an optional sharedPrefix for candidate batching).
Signature:
evaluateChoiceBatch(texts: string[], question: ChoiceQuestion, sharedPrefix?: string): Promise<ChoiceResult[]>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| texts | string[] | The input texts to be evaluated. |
| question | ChoiceQuestion | The choice question to evaluate. |
| sharedPrefix | string | An optional prefix shared by all inputs. One result per input text. |
Returns:
Promise<ChoiceResult[]>
DecisionMaker.evaluateScore()
Evaluates an Ordinal Score rubric against input text or multimodal context.
Signature:
evaluateScore(text: string | DecisionContextInput, question: ScoreQuestion): Promise<ScoreResult>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| text | string | DecisionContextInput | The input text or multimodal context to be evaluated. |
| question | ScoreQuestion | The score question to evaluate. The score evaluation result. |
Returns:
Promise<ScoreResult>
DecisionMaker.evaluateScoreBatch()
Evaluates an Ordinal Score rubric against a batch of input texts (with an optional sharedPrefix for candidate batching).
Signature:
evaluateScoreBatch(texts: string[], question: ScoreQuestion, sharedPrefix?: string): Promise<ScoreResult[]>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| texts | string[] | The input texts to be evaluated. |
| question | ScoreQuestion | The score question to evaluate. |
| sharedPrefix | string | An optional prefix shared by all inputs. One result per input text. |
Returns:
Promise<ScoreResult[]>
DecisionMaker.measureContextUsage()
Estimates the total token usage for evaluating input (and optional per-call context) against the session schema.
Signature:
measureContextUsage(input: string, options?: ClassifierEvaluateOptions): Promise<number>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| input | string | The input text to be evaluated. |
| options | ClassifierEvaluateOptions | Optional per-call evaluation options. |
Returns:
Promise<number>
DecisionMaker.prewarm()
Prewarms the underlying engine KV/prefix cache for the given schema.
Signature:
prewarm(schema: ClassifierSchema): Promise<void>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| schema | ClassifierSchema | The schema whose shared prefix should be prewarmed. |
Returns:
Promise<void>
DecisionMaker.setOptions()
Sets the options for the DecisionMaker and initializes the underlying engine. Options cannot be updated once the engine has been created.
Signature:
setOptions(options: DecisionMakerOptions): Promise<void>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| options | DecisionMakerOptions | The options for the DecisionMaker. |
Returns:
Promise<void>
DecisionMaker.setSchema()
Updates the session-bound ClassifierSchema used by classify().
Signature:
setSchema(schema: ClassifierSchema): void;
Parameters
| Parameter | Type | Description |
|---|---|---|
| schema | ClassifierSchema | The schema to bind to this session. |
Returns:
void