Documentation

Build LLM-powered agents
with production-ready TypeScript

DSPy for TypeScript. Working with LLMs is complex—they don't always do what you want. DSPy makes it easier to build amazing things with LLMs. Just define your inputs and outputs (signature) and an efficient prompt is auto-generated and used. Connect together various signatures to build complex systems and workflows using LLMs.

15+ LLM Providers
End-to-end Streaming
Auto Prompt Tuning

AxMiPRO

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/dsp/optimizers/miproV2.ts#L42

Abstract base class for optimizers that provides common functionality and standardized handling of AxOptimizerArgs

Extends

Constructors

Constructor

new AxMiPRO(args: Readonly<AxOptimizerArgs>): AxMiPRO;

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/dsp/optimizers/miproV2.ts#L81

Parameters

ParameterType
argsReadonly<AxOptimizerArgs>

Returns

AxMiPRO

Overrides

AxBaseOptimizer.constructor

Methods

compile()

compile<IN, OUT>(
   program: Readonly<AxGen<IN, OUT>>, 
   examples: readonly AxTypedExample<IN>[], 
   metricFn: AxMetricFn, 
options?: AxCompileOptions): Promise<AxMiPROResult<IN, OUT>>;

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/dsp/optimizers/miproV2.ts#L523

The main compile method to run MIPROv2 optimization

Type Parameters

Type Parameter
IN
OUT extends AxGenOut

Parameters

ParameterType
programReadonly<AxGen<IN, OUT>>
examplesreadonly AxTypedExample<IN>[]
metricFnAxMetricFn
options?AxCompileOptions

Returns

Promise<AxMiPROResult<IN, OUT>>

Overrides

AxBaseOptimizer.compile


compilePareto()

compilePareto<IN, OUT>(
   program: Readonly<AxGen<IN, OUT>>, 
   examples: readonly AxTypedExample<IN>[], 
   metricFn: AxMultiMetricFn, 
options?: AxCompileOptions): Promise<AxParetoResult<OUT>>;

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/dsp/optimizer.ts#L1559

Multi-objective optimization using Pareto frontier Default implementation that leverages the single-objective compile method

Type Parameters

Type Parameter
IN
OUT extends AxGenOut

Parameters

ParameterTypeDescription
programReadonly<AxGen<IN, OUT>>The program to optimize
examplesreadonly AxTypedExample<IN>[]Training examples
metricFnAxMultiMetricFnMulti-objective metric function that returns multiple scores
options?AxCompileOptionsOptional configuration options

Returns

Promise<AxParetoResult<OUT>>

Pareto optimization result with frontier of non-dominated solutions

Inherited from

AxBaseOptimizer.compilePareto


compileStream()

compileStream<IN, OUT>(
   program: Readonly<AxGen<IN, OUT>>, 
   examples: readonly AxTypedExample<IN>[], 
   metricFn: AxMetricFn, 
options?: AxCompileOptions): AsyncIterableIterator<AxOptimizationProgress>;

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/dsp/optimizer.ts#L1446

Optimize a program with real-time streaming updates

Type Parameters

Type Parameter
IN
OUT extends AxGenOut

Parameters

ParameterTypeDescription
programReadonly<AxGen<IN, OUT>>The program to optimize
examplesreadonly AxTypedExample<IN>[]Training examples
metricFnAxMetricFnEvaluation metric function
options?AxCompileOptionsOptional configuration options

Returns

AsyncIterableIterator<AxOptimizationProgress>

Async iterator yielding optimization progress

Inherited from

AxBaseOptimizer.compileStream


configureAuto()

configureAuto(level: "medium" | "light" | "heavy"): void;

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/dsp/optimizers/miproV2.ts#L175

Configures the optimizer for light, medium, or heavy optimization

Parameters

ParameterTypeDescription
level"medium" | "light" | "heavy"The optimization level: “light”, “medium”, or “heavy”

Returns

void


getConfiguration()

getConfiguration(): Record<string, unknown>;

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/dsp/optimizers/miproV2.ts#L594

Get optimizer-specific configuration

Returns

Record<string, unknown>

Current optimizer configuration


getStats()

getStats(): AxOptimizationStats;

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/dsp/optimizer.ts#L2492

Get current optimization statistics

Returns

AxOptimizationStats

Current optimization statistics

Inherited from

AxBaseOptimizer.getStats


reset()

reset(): void;

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/dsp/optimizers/miproV2.ts#L658

Reset optimizer state for reuse with different programs

Returns

void

Overrides

AxBaseOptimizer.reset


updateConfiguration()

updateConfiguration(config: Readonly<Record<string, unknown>>): void;

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/dsp/optimizers/miproV2.ts#L621

Update optimizer configuration

Parameters

ParameterTypeDescription
configReadonly<Record<string, unknown>>New configuration to merge with existing

Returns

void


validateProgram()

validateProgram<IN, OUT>(_program: Readonly<AxGen<IN, OUT>>): object;

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/dsp/optimizers/miproV2.ts#L669

Validate that the optimizer can handle the given program

Type Parameters

Type Parameter
IN
OUT extends AxGenOut

Parameters

ParameterType
_programReadonly<AxGen<IN, OUT>>

Returns

object

Validation result with any issues found

NameType
issuesstring[]
isValidboolean
suggestionsstring[]