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

AxProgram

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L22

Extended by

Type Parameters

Type ParameterDefault type
INany
OUTany

Implements

Constructors

Constructor

TypeScript
new AxProgram<IN, OUT>(signature: 
  | undefined
  | string
  | Readonly<AxSignature<Record<string, any>, Record<string, any>>>
| Readonly<AxSignatureConfig>, options?: Readonly<AxProgramOptions>): AxProgram<IN, OUT>;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L41

Parameters

ParameterType
signature| undefined | string | Readonly<AxSignature<Record<string, any>, Record<string, any>>> | Readonly<AxSignatureConfig>
options?Readonly<AxProgramOptions>

Returns

AxProgram<IN, OUT>

Methods

applyOptimization()

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

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L370

Parameters

ParameterType
optimizedProgramAxOptimizedProgram<OUT>

Returns

void

Implementation of

AxTunable.applyOptimization


applyOptimizedComponents()

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

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L444

Broadcast component updates across this subtree. Each node filters keys belonging to itself and dispatches via applyLocalOptimizedComponents.

Parameters

ParameterType
updatesReadonly<Record<string, string>>

Returns

void

Implementation of

AxTunable.applyOptimizedComponents


getChatLog()

TypeScript
getChatLog(): readonly AxChatLogEntry[];

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L178

Returns

readonly AxChatLogEntry[]

Implementation of

AxUsable.getChatLog


getId()

TypeScript
getId(): string;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L96

Returns

string

Implementation of

AxTunable.getId


getOptimizableComponents()

TypeScript
getOptimizableComponents(): readonly AxOptimizableComponent[];

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L393

Walks the program tree and emits one AxOptimizableComponent per string-valued artifact reachable from this node. Subclasses override localOptimizableComponents() to add their own; tree traversal is handled here so callers never need to recurse.

Returns

readonly AxOptimizableComponent[]

Implementation of

AxTunable.getOptimizableComponents


getSignature()

TypeScript
getSignature(): AxSignature;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L69

Returns

AxSignature


getTraces()

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

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L151

Returns

AxProgramTrace<IN, OUT>[]

Implementation of

AxTunable.getTraces


getUsage()

TypeScript
getUsage(): AxModelUsage & object[];

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L165

Returns

AxModelUsage & object[]

Implementation of

AxUsable.getUsage


namedProgramInstances()

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

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L337

Returns

AxNamedProgramInstance<IN, OUT>[]

Implementation of

AxTunable.namedProgramInstances


namedPrograms()

TypeScript
namedPrograms(): object[];

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L306

Returns all programs in the hierarchy with their IDs and signatures. Use this to discover the IDs needed for setDemos().

Equivalent to DSPy’s named_parameters().

Example

TypeScript
agent.setId('qa');
console.log(agent.namedPrograms());
// [
//   { id: 'qa.actor', signature: '... -> javascriptCode' },
//   { id: 'qa.responder', signature: '... -> answer' },
// ]

Returns

object[]


register()

TypeScript
register(prog: Readonly<AxTunable<IN, OUT> & AxUsable>, name?: string): void;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L100

Parameters

ParameterType
progReadonly<AxTunable<IN, OUT> & AxUsable>
name?string

Returns

void


resetUsage()

TypeScript
resetUsage(): void;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L202

Returns

void

Implementation of

AxUsable.resetUsage


setDemos()

TypeScript
setDemos(demos: readonly AxProgramDemos<IN, OUT>[], options?: object): void;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L211

Parameters

ParameterType
demosreadonly AxProgramDemos<IN, OUT>[]
options?{ modelConfig?: Record<string, unknown>; }
options.modelConfig?Record<string, unknown>

Returns

void

Implementation of

AxTunable.setDemos


setDescription()

TypeScript
setDescription(description: string): void;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L87

Parameters

ParameterType
descriptionstring

Returns

void


setExamples()

TypeScript
setExamples(examples: Readonly<AxProgramExamples<IN, OUT>>, options?: Readonly<AxSetExamplesOptions>): void;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L118

Parameters

ParameterType
examplesReadonly<AxProgramExamples<IN, OUT>>
options?Readonly<AxSetExamplesOptions>

Returns

void


setId()

TypeScript
setId(id: string): void;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L111

Parameters

ParameterType
idstring

Returns

void

Implementation of

AxTunable.setId


setSignature()

TypeScript
setSignature(signature: 
  | string
  | Readonly<AxSignature<Record<string, any>, Record<string, any>>>
  | Readonly<AxSignatureConfig>): void;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/program.ts#L73

Parameters

ParameterType
signature| string | Readonly<AxSignature<Record<string, any>, Record<string, any>>> | Readonly<AxSignatureConfig>

Returns

void

Docs