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

AxBootstrapFewShot

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/dsp/optimizers/bootstrapFewshot.ts#L24

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

Extends

Type Parameters

Type ParameterDefault type
INany
OUT extends AxGenOutany

Constructors

Constructor

new AxBootstrapFewShot<IN, OUT>(args: Readonly<AxOptimizerArgs & object>): AxBootstrapFewShot<IN, OUT>;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/dsp/optimizers/bootstrapFewshot.ts#L39

Parameters

ParameterType
argsReadonly<AxOptimizerArgs & object>

Returns

AxBootstrapFewShot<IN, OUT>

Overrides

AxBaseOptimizer.constructor

Methods

compile()

compile(
   program: Readonly<AxGen<IN, OUT>>, 
   metricFn: AxMetricFn, 
options?: AxBootstrapCompileOptions): Promise<AxOptimizerResult<OUT>>;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/dsp/optimizers/bootstrapFewshot.ts#L175

Abstract method that must be implemented by concrete optimizers

Parameters

ParameterType
programReadonly<AxGen<IN, OUT>>
metricFnAxMetricFn
options?AxBootstrapCompileOptions

Returns

Promise<AxOptimizerResult<OUT>>

Overrides

AxBaseOptimizer.compile


compilePareto()

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

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/dsp/optimizer.ts#L1579

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

Parameters

ParameterTypeDescription
programReadonly<AxGen<IN, OUT>>The program to optimize
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(
   program: Readonly<AxGen<IN, OUT>>, 
   metricFn: AxMetricFn, 
options?: AxCompileOptions): AsyncIterableIterator<AxOptimizationProgress>;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/dsp/optimizer.ts#L1468

Optimize a program with real-time streaming updates

Parameters

ParameterTypeDescription
programReadonly<AxGen<IN, OUT>>The program to optimize
metricFnAxMetricFnEvaluation metric function
options?AxCompileOptionsOptional configuration options

Returns

AsyncIterableIterator<AxOptimizationProgress>

Async iterator yielding optimization progress

Inherited from

AxBaseOptimizer.compileStream


getStats()

getStats(): AxOptimizationStats;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/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/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/dsp/optimizer.ts#L2496

Reset optimizer state for reuse with different programs

Returns

void

Inherited from

AxBaseOptimizer.reset