AxFlow Generated TypeScript API reference. typescript api api/reference build/apidocs/Class.AxFlow.md class AxFlow

AxFlow

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L129

Interface for flows that can be tuned, executed, and used in compositions. Provides methods for building and executing complex AI workflows.

Type Parameters

Type ParameterDefault type
IN extends Record<string, any>-
OUT-
TNodes extends Record<string, AxProgrammable<any, any>>Record<string, never>
TState extends AxFlowStateIN

Implements

Methods

applyOptimization()

TypeScript
applyOptimization(optimizedProgram: AxOptimizedProgram<any>): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1142

Parameters

ParameterType
optimizedProgramAxOptimizedProgram<any>

Returns

void

Implementation of

AxFlowable.applyOptimization


applyOptimizedComponents()

TypeScript
applyOptimizedComponents(updates: Readonly<Record<string, string>>): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1169

Apply a map of componentKey → newValue updates produced by an optimizer. Each program filters keys belonging to itself and dispatches internally. Unknown keys are silently ignored, which lets parents broadcast a single map across the whole subtree.

Parameters

ParameterType
updatesReadonly<Record<string, string>>

Returns

void

Implementation of

AxFlowable.applyOptimizedComponents


b()

TypeScript
b(predicate: (_state: TState) => unknown): this;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1198

Parameters

ParameterType
predicate(_state: TState) => unknown

Returns

this


branch()

TypeScript
branch(predicate: (_state: TState) => unknown): this;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1185

Parameters

ParameterType
predicate(_state: TState) => unknown

Returns

this


derive()

TypeScript
derive<T>(
   outputFieldName: string, 
   inputFieldName: string, 
   transformFn: (value: any, index?: number, state?: TState) => T, 
   options?: object): this;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1507

Type Parameters

Type Parameter
T

Parameters

ParameterType
outputFieldNamestring
inputFieldNamestring
transformFn(value: any, index?: number, state?: TState) => T
options?{ batchSize?: number; }
options.batchSize?number

Returns

this


description()

TypeScript
description(name: string, description: string): this;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L514

Parameters

ParameterType
namestring
descriptionstring

Returns

this


e()

TypeScript
e<TNodeName, TAI>(
   nodeName: TNodeName, 
   mapping: (_state: TState) => GetGenIn<TNodes[TNodeName]>, 
dynamicContext?: AxFlowDynamicContext<TAI>): AxFlow<IN, OUT, TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1126

Type Parameters

Type Parameter
TNodeName extends string
TAI extends Readonly<AxAIService<unknown, unknown, string>>

Parameters

ParameterType
nodeNameTNodeName
mapping(_state: TState) => GetGenIn<TNodes[TNodeName]>
dynamicContext?AxFlowDynamicContext<TAI>

Returns

AxFlow<IN, OUT, TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>


end()

TypeScript
end(): this;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1503

Returns

this


endWhile()

TypeScript
endWhile(): this;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1455

Returns

this


execute()

TypeScript
execute<TNodeName, TAI>(
   nodeName: TNodeName, 
   mapping: (_state: TState) => GetGenIn<TNodes[TNodeName]>, 
dynamicContext?: AxFlowDynamicContext<TAI>): AxFlow<IN, OUT, TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1104

Type Parameters

Type Parameter
TNodeName extends string
TAI extends Readonly<AxAIService<unknown, unknown, string>>

Parameters

ParameterType
nodeNameTNodeName
mapping(_state: TState) => GetGenIn<TNodes[TNodeName]>
dynamicContext?AxFlowDynamicContext<TAI>

Returns

AxFlow<IN, OUT, TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>


fb()

TypeScript
fb(
   condition: (_state: TState) => boolean, 
   targetLabel: string, 
   maxIterations: number): this;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1428

Parameters

ParameterTypeDefault value
condition(_state: TState) => booleanundefined
targetLabelstringundefined
maxIterationsnumber10

Returns

this


feedback()

TypeScript
feedback(
   condition: (_state: TState) => boolean, 
   targetLabel: string, 
   maxIterations: number): this;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1376

Parameters

ParameterTypeDefault value
condition(_state: TState) => booleanundefined
targetLabelstringundefined
maxIterationsnumber10

Returns

this


forward()

TypeScript
forward<T>(
   ai: T, 
   values: IN, 
options?: Readonly<AxFlowForwardOptions<T>>): Promise<OUT>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L651

Type Parameters

Type Parameter
T extends Readonly<AxAIService<unknown, unknown, string>>

Parameters

ParameterType
aiT
valuesIN
options?Readonly<AxFlowForwardOptions<T>>

Returns

Promise<OUT>

Implementation of

AxFlowable.forward


getChatLog()

TypeScript
getChatLog(): readonly AxChatLogEntry[];

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L559

Returns

readonly AxChatLogEntry[]

Implementation of

AxFlowable.getChatLog


getExecutionPlan()

TypeScript
getExecutionPlan(): object;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1548

Returns

object

NameType
autoParallelEnabledboolean
groups?AxFlowExecutionPlanGroup[]
maxParallelismnumber
parallelGroupsnumber
steps?AxFlowExecutionPlanStep[]
totalStepsnumber

getId()

TypeScript
getId(): string;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L474

Returns

string

Implementation of

AxFlowable.getId


getNodePrograms()

TypeScript
getNodePrograms(): readonly object[];

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L591

Returns

readonly object[]


getOptimizableComponents()

TypeScript
getOptimizableComponents(): readonly AxOptimizableComponent[];

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1153

Enumerate all string-valued artifacts this program tree exposes for reflective optimization (instructions, signature descriptions, function names/descriptions, agent system prompts, etc.). Composite programs flat-map their children’s components and append their own.

The optimizer never walks the tree — traversal is encapsulated here.

Returns

readonly AxOptimizableComponent[]

Implementation of

AxFlowable.getOptimizableComponents


getSignature()

TypeScript
getSignature(): AxSignature;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1596

Returns

AxSignature

Implementation of

AxFlowable.getSignature


getTraces()

TypeScript
getTraces(): AxProgramTrace<IN, OUT>[];

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L494

Returns

AxProgramTrace<IN, OUT>[]

Implementation of

AxFlowable.getTraces


getTracesReport()

TypeScript
getTracesReport(): Record<string, AxProgramTrace<any, any>[]>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L620

Returns

Record<string, AxProgramTrace<any, any>[]>


getUsage()

TypeScript
getUsage(): AxModelUsage & object[];

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L555

Returns

AxModelUsage & object[]

Implementation of

AxFlowable.getUsage


getUsageReport()

TypeScript
getUsageReport(): Record<string, AxProgramUsage[]>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L583

Returns

Record<string, AxProgramUsage[]>


l()

TypeScript
l(label: string): this;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1053

Parameters

ParameterType
labelstring

Returns

this


label()

TypeScript
label(label: string): this;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1042

Parameters

ParameterType
labelstring

Returns

this


m()

Call Signature

TypeScript
m<TNewState>(transform: (_state: TState) => TNewState): AxFlow<IN, OUT, TNodes, TNewState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L999

Type Parameters
Type Parameter
TNewState extends AxFlowState
Parameters
ParameterType
transform(_state: TState) => TNewState
Returns

AxFlow<IN, OUT, TNodes, TNewState>

Call Signature

TypeScript
m<TNewState>(transform: (_state: TState) => Promise<TNewState>): AxFlow<IN, OUT, TNodes, TNewState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1002

Type Parameters
Type Parameter
TNewState extends AxFlowState
Parameters
ParameterType
transform(_state: TState) => Promise<TNewState>
Returns

AxFlow<IN, OUT, TNodes, TNewState>

Call Signature

TypeScript
m<TNewState>(transforms: (_state: TState) => TNewState[], options: object): AxFlow<IN, OUT, TNodes, TNewState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1005

Type Parameters
Type Parameter
TNewState extends AxFlowState
Parameters
ParameterType
transforms(_state: TState) => TNewState[]
options{ parallel: true; }
options.paralleltrue
Returns

AxFlow<IN, OUT, TNodes, TNewState>

Call Signature

TypeScript
m<TNewState>(transforms: (_state: TState) => Promise<TNewState>[], options: object): AxFlow<IN, OUT, TNodes, TNewState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1009

Type Parameters
Type Parameter
TNewState extends AxFlowState
Parameters
ParameterType
transforms(_state: TState) => Promise<TNewState>[]
options{ parallel: true; }
options.paralleltrue
Returns

AxFlow<IN, OUT, TNodes, TNewState>


map()

Call Signature

TypeScript
map<TNewState>(transform: (_state: TState) => TNewState): AxFlow<IN, OUT, TNodes, TNewState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L948

Type Parameters
Type Parameter
TNewState extends AxFlowState
Parameters
ParameterType
transform(_state: TState) => TNewState
Returns

AxFlow<IN, OUT, TNodes, TNewState>

Call Signature

TypeScript
map<TNewState>(transform: (_state: TState) => Promise<TNewState>): AxFlow<IN, OUT, TNodes, TNewState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L951

Type Parameters
Type Parameter
TNewState extends AxFlowState
Parameters
ParameterType
transform(_state: TState) => Promise<TNewState>
Returns

AxFlow<IN, OUT, TNodes, TNewState>

Call Signature

TypeScript
map<TNewState>(transforms: (_state: TState) => TNewState[], options: object): AxFlow<IN, OUT, TNodes, TNewState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L954

Type Parameters
Type Parameter
TNewState extends AxFlowState
Parameters
ParameterType
transforms(_state: TState) => TNewState[]
options{ parallel: true; }
options.paralleltrue
Returns

AxFlow<IN, OUT, TNodes, TNewState>

Call Signature

TypeScript
map<TNewState>(transforms: (_state: TState) => Promise<TNewState>[], options: object): AxFlow<IN, OUT, TNodes, TNewState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L958

Type Parameters
Type Parameter
TNewState extends AxFlowState
Parameters
ParameterType
transforms(_state: TState) => Promise<TNewState>[]
options{ parallel: true; }
options.paralleltrue
Returns

AxFlow<IN, OUT, TNodes, TNewState>

Call Signature

TypeScript
map<TNewState>(transform: (_state: TState) => TNewState | Promise<TNewState>, options?: object): AxFlow<IN, OUT, TNodes, TNewState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L962

Type Parameters
Type Parameter
TNewState extends AxFlowState
Parameters
ParameterType
transform(_state: TState) => TNewState | Promise<TNewState>
options?{ parallel?: boolean; }
options.parallel?boolean
Returns

AxFlow<IN, OUT, TNodes, TNewState>


merge()

TypeScript
merge<TMergedState>(): AxFlow<IN, OUT, TNodes, TMergedState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1217

Type Parameters

Type ParameterDefault type
TMergedState extends AxFlowStateTState

Returns

AxFlow<IN, OUT, TNodes, TMergedState>


mg()

TypeScript
mg<TMergedState>(): AxFlow<IN, OUT, TNodes, TMergedState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1261

Type Parameters

Type ParameterDefault type
TMergedState extends AxFlowStateTState

Returns

AxFlow<IN, OUT, TNodes, TMergedState>


n()

Call Signature

TypeScript
n<TName, TSig>(name: TName, signature: TSig): AxFlow<IN, OUT, TNodes & { [K in string]: InferAxGen<TSig> }, TState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L913

Type Parameters
Type Parameter
TName extends string
TSig extends string
Parameters
ParameterType
nameTName
signatureTSig
Returns

AxFlow<IN, OUT, TNodes & { [K in string]: InferAxGen<TSig> }, TState>

Call Signature

TypeScript
n<TName>(name: TName, signature: AxSignature): AxFlow<IN, OUT, TNodes & { [K in string]: AxGen<AxGenIn, AxGenOut> }, TState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L917

Type Parameters
Type Parameter
TName extends string
Parameters
ParameterType
nameTName
signatureAxSignature
Returns

AxFlow<IN, OUT, TNodes & { [K in string]: AxGen<AxGenIn, AxGenOut> }, TState>

Call Signature

TypeScript
n<TName, TProgram>(name: TName, programClass: TProgram): AxFlow<IN, OUT, TNodes & { [K in string]: InstanceType<TProgram> }, TState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L926

Type Parameters
Type Parameter
TName extends string
TProgram extends () => AxProgrammable<any, any>
Parameters
ParameterType
nameTName
programClassTProgram
Returns

AxFlow<IN, OUT, TNodes & { [K in string]: InstanceType<TProgram> }, TState>

Call Signature

TypeScript
n<TName, TProgram>(name: TName, programInstance: TProgram): AxFlow<IN, OUT, TNodes & { [K in string]: TProgram }, TState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L933

Type Parameters
Type Parameter
TName extends string
TProgram extends AxProgrammable<any, any, string>
Parameters
ParameterType
nameTName
programInstanceTProgram
Returns

AxFlow<IN, OUT, TNodes & { [K in string]: TProgram }, TState>


namedProgramInstances()

TypeScript
namedProgramInstances(): AxNamedProgramInstance<IN, OUT>[];

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L489

Returns

AxNamedProgramInstance<IN, OUT>[]

Implementation of

AxFlowable.namedProgramInstances


namedPrograms()

TypeScript
namedPrograms(): object[];

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L484

Returns

object[]


node()

Call Signature

TypeScript
node<TName, TSig>(name: TName, signature: TSig): AxFlow<IN, OUT, TNodes & { [K in string]: InferAxGen<TSig> }, TState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L840

Type Parameters
Type Parameter
TName extends string
TSig extends string
Parameters
ParameterType
nameTName
signatureTSig
Returns

AxFlow<IN, OUT, TNodes & { [K in string]: InferAxGen<TSig> }, TState>

Call Signature

TypeScript
node<TName>(name: TName, signature: AxSignature): AxFlow<IN, OUT, TNodes & { [K in string]: AxGen<AxGenIn, AxGenOut> }, TState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L845

Type Parameters
Type Parameter
TName extends string
Parameters
ParameterType
nameTName
signatureAxSignature
Returns

AxFlow<IN, OUT, TNodes & { [K in string]: AxGen<AxGenIn, AxGenOut> }, TState>

Call Signature

TypeScript
node<TName, TProgram>(name: TName, programClass: TProgram): AxFlow<IN, OUT, TNodes & { [K in string]: InstanceType<TProgram> }, TState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L855

Type Parameters
Type Parameter
TName extends string
TProgram extends () => AxProgrammable<any, any>
Parameters
ParameterType
nameTName
programClassTProgram
Returns

AxFlow<IN, OUT, TNodes & { [K in string]: InstanceType<TProgram> }, TState>

Call Signature

TypeScript
node<TName, TProgram>(name: TName, programInstance: TProgram): AxFlow<IN, OUT, TNodes & { [K in string]: TProgram }, TState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L863

Type Parameters
Type Parameter
TName extends string
TProgram extends AxProgrammable<any, any, string>
Parameters
ParameterType
nameTName
programInstanceTProgram
Returns

AxFlow<IN, OUT, TNodes & { [K in string]: TProgram }, TState>


nodeExtended()

TypeScript
nodeExtended<TName>(
   name: TName, 
   baseSignature: 
  | string
  | AxSignature<Record<string, any>, Record<string, any>>, 
extensions: object): AxFlow<IN, OUT, TNodes & { [K in string]: AxGen<AxGenIn, AxGenOut> }, TState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1601

Type Parameters

Type Parameter
TName extends string

Parameters

ParameterType
nameTName
baseSignature| string | AxSignature<Record<string, any>, Record<string, any>>
extensions{ appendInputs?: object[]; appendOutputs?: object[]; prependInputs?: object[]; prependOutputs?: object[]; }
extensions.appendInputs?object[]
extensions.appendOutputs?object[]
extensions.prependInputs?object[]
extensions.prependOutputs?object[]

Returns

AxFlow<IN, OUT, TNodes & { [K in string]: AxGen<AxGenIn, AxGenOut> }, TState>


nx()

TypeScript
nx<TName>(
   name: TName, 
   baseSignature: 
  | string
  | AxSignature<Record<string, any>, Record<string, any>>, 
extensions: object): AxFlow<IN, OUT, TNodes & { [K in string]: AxGen<AxGenIn, AxGenOut> }, TState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1636

Type Parameters

Type Parameter
TName extends string

Parameters

ParameterType
nameTName
baseSignature| string | AxSignature<Record<string, any>, Record<string, any>>
extensions{ appendInputs?: object[]; appendOutputs?: object[]; prependInputs?: object[]; prependOutputs?: object[]; }
extensions.appendInputs?object[]
extensions.appendOutputs?object[]
extensions.prependInputs?object[]
extensions.prependOutputs?object[]

Returns

AxFlow<IN, OUT, TNodes & { [K in string]: AxGen<AxGenIn, AxGenOut> }, TState>


p()

TypeScript
p(branches: AxFlowTypedParallelBranch<TNodes, TState>[]): object;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1367

Parameters

ParameterType
branchesAxFlowTypedParallelBranch<TNodes, TState>[]

Returns

object

NameType
merge()(resultKey: TResultKey, mergeFunction: (…_results: unknown[]) => T) =>

parallel()

TypeScript
parallel(branches: AxFlowTypedParallelBranch<TNodes, TState>[]): object;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1270

Parameters

ParameterType
branchesAxFlowTypedParallelBranch<TNodes, TState>[]

Returns

object

NameType
merge()(resultKey: TResultKey, mergeFunction: (…_results: unknown[]) => T) =>

r()

TypeScript
r<TNewOut>(transform: (_state: TState) => TNewOut): AxFlow<IN, TNewOut, TNodes, TState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1036

Type Parameters

Type Parameter
TNewOut extends Record<string, unknown>

Parameters

ParameterType
transform(_state: TState) => TNewOut

Returns

AxFlow<IN, TNewOut, TNodes, TState>


recordChatLog()

TypeScript
recordChatLog(_nodeName: string, entries: AxChatLogEntry[]): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L638

Parameters

ParameterType
_nodeNamestring
entriesAxChatLogEntry[]

Returns

void

Implementation of

TypeScript
AxFlowNodeExecutionRecorder.recordChatLog

recordTraces()

TypeScript
recordTraces(nodeName: string, traces: AxProgramTrace<any, any>[]): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L633

Parameters

ParameterType
nodeNamestring
tracesAxProgramTrace<any, any>[]

Returns

void

Implementation of

TypeScript
AxFlowNodeExecutionRecorder.recordTraces

recordUsage()

TypeScript
recordUsage(nodeName: string, usage: AxModelUsage & object[]): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L628

Parameters

ParameterType
nodeNamestring
usageAxModelUsage & object[]

Returns

void

Implementation of

TypeScript
AxFlowNodeExecutionRecorder.recordUsage

resetChatLog()

TypeScript
resetChatLog(): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L579

Returns

void


resetTraces()

TypeScript
resetTraces(): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L575

Returns

void


resetUsage()

TypeScript
resetUsage(): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L563

Returns

void

Implementation of

AxFlowable.resetUsage


returns()

TypeScript
returns<TNewOut>(transform: (_state: TState) => TNewOut): AxFlow<IN, TNewOut, TNodes, TState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1022

Type Parameters

Type Parameter
TNewOut extends Record<string, unknown>

Parameters

ParameterType
transform(_state: TState) => TNewOut

Returns

AxFlow<IN, TNewOut, TNodes, TState>


setAllNodeInstructions()

TypeScript
setAllNodeInstructions(map: Readonly<Record<string, string>>): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L614

Parameters

ParameterType
mapReadonly<Record<string, string>>

Returns

void


setDemos()

TypeScript
setDemos(demos: readonly AxProgramDemos<IN, OUT, keyof TNodes extends never ? string : `${string}.${string & keyof TNodes}`>[], options?: object): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L502

Parameters

ParameterType
demosreadonly AxProgramDemos<IN, OUT, keyof TNodes extends never ? string : `${string}.${string & keyof TNodes}`>[]
options?{ modelConfig?: Record<string, unknown>; }
options.modelConfig?Record<string, unknown>

Returns

void

Implementation of

AxFlowable.setDemos


setId()

TypeScript
setId(id: string): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L479

Parameters

ParameterType
idstring

Returns

void

Implementation of

AxFlowable.setId


setNodeInstruction()

TypeScript
setNodeInstruction(name: string, instruction: string): boolean;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L601

Parameters

ParameterType
namestring
instructionstring

Returns

boolean


stop()

TypeScript
stop(): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L228

Returns

void


streamingForward()

TypeScript
streamingForward<T>(
   ai: T, 
   values: IN, 
options?: Readonly<AxProgramStreamingForwardOptionsWithModels<T>>): AxGenStreamingOut<OUT>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L642

Type Parameters

Type Parameter
T extends Readonly<AxAIService<unknown, unknown, string>>

Parameters

ParameterType
aiT
valuesIN
options?Readonly<AxProgramStreamingForwardOptionsWithModels<T>>

Returns

AxGenStreamingOut<OUT>

Implementation of

AxFlowable.streamingForward


toFunction()

TypeScript
toFunction(): AxFunction;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L521

Returns

AxFunction


toString()

TypeScript
toString(options?: AxFlowMermaidRenderOptions): string;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1581

Renders this flow as a mermaid flowchart in the AxFlow mermaid dialect: node contracts are emitted as %%ax nodeId: <signature> comment directives (invisible to mermaid renderers) and control flow becomes nodes and edges — branch decisions render as diamonds with labeled out-edges, feedback loops as back-edges with max N caps.

String(flow) and template-literal interpolation yield the diagram — mirroring AxSignature.toString() returning the signature string — and flow(String(f)) round-trips exactly. Pass options for render control, e.g. f.toString({ direction: 'LR' }) (like Number.toString(radix)).

Flows built with opaque closures (map/derive/returns/custom conditions) render with placeholder nodes plus %% bind ... comments naming what must be supplied via bindings to re-import the diagram. A while loop renders with its body inlined once and a back-edge (the zero-iteration exit is not drawable).

Parameters

ParameterType
options?AxFlowMermaidRenderOptions

Returns

string


w()

TypeScript
w(value: unknown): this;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1213

Parameters

ParameterType
valueunknown

Returns

this


wh()

TypeScript
wh(condition: (_state: TState) => boolean, maxIterations: number): this;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1451

Parameters

ParameterTypeDefault value
condition(_state: TState) => booleanundefined
maxIterationsnumber100

Returns

this


when()

TypeScript
when(value: unknown): this;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1202

Parameters

ParameterType
valueunknown

Returns

this


while()

TypeScript
while(condition: (state: TState) => boolean, maxIterations: number): this;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1436

Parameters

ParameterTypeDefault value
condition(state: TState) => booleanundefined
maxIterationsnumber100

Returns

this


create()

TypeScript
static create<IN, OUT, TNodes, TState>(options?: AxFlowOptions): AxFlow<IN, OUT, TNodes, TState>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L212

Type Parameters

Type ParameterDefault type
IN extends Record<string, any>Record<string, unknown>
OUTobject
TNodes extends Record<string, AxProgrammable<any, any, string>>Record<string, never>
TState extends AxFlowStateIN

Parameters

ParameterType
options?AxFlowOptions

Returns

AxFlow<IN, OUT, TNodes, TState>


patchLastStep()

TypeScript
static patchLastStep(target: AxFlow<any, any, any, any>, patch: object): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/flow/flow.ts#L1662

Internal

Patches the most recently added step. Used by the mermaid compiler (flow(text)) to record decision fields, synthetic-returns markers, and the declared reads/writes of generated projection steps (so signature inference sees through them) on steps it just emitted through the public builder.

Parameters

ParameterType
targetAxFlow<any, any, any, any>
patch{ meta?: (existing: undefined | AxFlowStepMeta) => undefined | AxFlowStepMeta; reads?: readonly string[]; writes?: readonly string[]; }
patch.meta?(existing: undefined | AxFlowStepMeta) => undefined | AxFlowStepMeta
patch.reads?readonly string[]
patch.writes?readonly string[]

Returns

void

Docs