Skip to content
API reference

testing

Import
import * as api from "@fungi.computer/mule/testing";
Kind Export Description
type alias FauxModelDefinition Credential-free model definition for the scripted provider.
type alias RegisterFauxProviderOptions Scripted provider configuration, independent of provider SDK declarations.
type alias FauxProviderState Counters retained by the scripted provider.
type alias FauxResponseFactory Function that observes a model request and supplies a scripted reply.
type alias FauxResponseStep A scripted reply or a factory that observes the normalized request.
type alias FauxModel Deterministic model and stream with Pi’s observable response state.
function fauxModel() Create a credential-free model for tests and runnable examples.

FauxModelDefinitiontype alias

Section titled “FauxModelDefinition”
Signature
type FauxModelDefinition = object;

Credential-free model definition for the scripted provider.

Signature
id: string;
Signature
optional name?: string;
Signature
optional reasoning?: boolean;
Signature
optional input?: ("text" | "image")[];
Signature
optional inputLimits?: Model<Api>["inputLimits"];
Signature
optional cost?: object;
Signature
input: number;
Signature
output: number;
Signature
cacheRead: number;
Signature
cacheWrite: number;
Signature
optional contextWindow?: number;
Signature
optional maxTokens?: number;

RegisterFauxProviderOptionstype alias

Section titled “RegisterFauxProviderOptions”
Signature
type RegisterFauxProviderOptions = object;

Scripted provider configuration, independent of provider SDK declarations.

Signature
optional api?: string;
Signature
optional provider?: string;
Signature
optional models?: FauxModelDefinition[];
Signature
optional deferred?: object;
Signature
optional pendingFetches?: number;
Signature
optional pollAfterMs?: number;
Signature
optional tokensPerSecond?: number;
Signature
optional tokenSize?: object;
Signature
optional min?: number;
Signature
optional max?: number;

FauxProviderStatetype alias

Section titled “FauxProviderState”
Signature
type FauxProviderState = object;

Counters retained by the scripted provider.

Signature
callCount: number;
Signature
deferredFetchCount: number;
Signature
cancelledDeferred: NonNullable < AssistantMessage["deferred"] > [];

FauxResponseFactorytype alias

Section titled “FauxResponseFactory”
Signature
type FauxResponseFactory = (
context,
options,
state,
model,
) => AssistantMessage | Promise<AssistantMessage>;

Function that observes a model request and supplies a scripted reply.

Parameter Type
context Context
options Parameters<MuleStreamFunction>[2]
state FauxProviderState
model Model<Api>

| AssistantMessage | Promise<AssistantMessage>


FauxResponseSteptype alias

Section titled “FauxResponseStep”
Signature
type FauxResponseStep = AssistantMessage | FauxResponseFactory;

A scripted reply or a factory that observes the normalized request.


FauxModeltype alias

Section titled “FauxModel”
Signature
type FauxModel = Readonly<{
model: Model<Api>;
stream: (...args) => AssistantMessageEventStream;
retryable: (message) => boolean;
setResponses: (replies) => void;
state: FauxProviderState;
getPendingResponseCount: () => number;
}>;

Deterministic model and stream with Pi’s observable response state.

Signature
function fauxModel(replies, options?): FauxModel;

Create a credential-free model for tests and runnable examples.

Parameter Type
replies readonly FauxResponseStep[]
options RegisterFauxProviderOptions

FauxModel