Skip to content

FauxModel

A scripted model for tests and examples. It is a real effect/ai LanguageModel, so generation takes the same path as with a provider: each request takes the next scripted response and streams it in token-sized deltas.

import { FauxModel, Harness } from "@effective-harness/core"
const faux = FauxModel.make()
faux.setResponses([
FauxModel.response([FauxModel.toolCall("read", { path: "a.txt" })], { stopReason: "toolUse" }),
FauxModel.response("Done.")
])
const HarnessLive = Harness.layer({ models: faux.models })

Since v0.0.0


A content block of a scripted answer.

Signature

type Content = TextContent | ThinkingContent | ToolCall

Source

Since v0.0.0

Signature

export interface Faux {
/** Replace the script. */
readonly setResponses: (steps: ReadonlyArray<Step>) => void
readonly appendResponses: (steps: ReadonlyArray<Step>) => void
readonly pendingResponses: () => number
/** Requests answered so far. */
readonly callCount: () => number
/** Status checks of deferred answers so far. */
readonly deferredFetchCount: () => number
/** Handles of the deferred answers cancelled so far. */
readonly cancelledDeferred: () => ReadonlyArray<DeferredHandle>
/** One catalog model per definition; all share the script. */
readonly models: ReadonlyArray<CatalogModel>
}

Source

Since v0.0.0

Signature

export interface ModelDefinition {
readonly id: string
readonly contextWindow?: number
readonly maxTokens?: number
}

Source

Since v0.0.0

Signature

export interface Options {
readonly provider?: string
readonly models?: ReadonlyArray<ModelDefinition>
/** Streaming speed; absent streams at once. */
readonly tokensPerSecond?: number
/** Tokens per delta (a token is 4 characters). Default 3 to 5. */
readonly tokenSize?: { readonly min?: number; readonly max?: number }
/**
* Deferred responses: a request that asks for one (`stream.deferred`) takes the next step but answers with a handle;
* a fetch answers it after `pendingFetches` checks that are still pending (default 0).
*/
readonly deferred?: { readonly pendingFetches?: number; readonly pollAfterMs?: number }
}

Source

Since v0.0.0

What a scripted step sees: the request as effect/ai built it.

Signature

export interface Request {
readonly prompt: Prompt.Prompt
/** Names of the tools offered. */
readonly tools: ReadonlyArray<string>
readonly modelId: string
/** Requests answered so far, this one included. */
readonly callCount: number
}

Source

Since v0.0.0

A scripted answer.

Signature

export interface Response {
readonly content: ReadonlyArray<Content>
/** Default `"stop"`. `"error"` fails the request with `errorMessage`. */
readonly stopReason?: "stop" | "length" | "toolUse" | "error"
readonly errorMessage?: string
/** Whether an error is worth retrying, like a rate limit. Default `false`. */
readonly retryable?: boolean
}

Source

Since v0.0.0

A response, or a function of the request; it may suspend, for example until a test lets it continue.

Signature

type Step = Response | ((request: Request) => Response | Effect.Effect<Response>)

Source

Since v0.0.0

A scripted model.

Signature

declare const make: (options?: Options) => Faux

Source

Since v0.0.0

The text of a prompt message, its tool calls and results rendered like pi’s faux model.

Signature

declare const messageText: (message: Prompt.Message) => string

Source

Since v0.0.0

A scripted answer from text or blocks.

Signature

declare const response: (
content: string | Content | ReadonlyArray<Content>,
options?: Omit<Response, "content">
) => Response

Source

Since v0.0.0

A text block.

Signature

declare const text: (value: string) => TextContent

Source

Since v0.0.0

A thinking block.

Signature

declare const thinking: (value: string) => ThinkingContent

Source

Since v0.0.0

A tool call; the ID defaults to a fresh one.

Signature

declare const toolCall: (
name: string,
args: { readonly [key: string]: Json },
options?: { readonly id?: string }
) => ToolCall

Source

Since v0.0.0