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

AxJudge

Defined in: https://github.com/ax-llm/ax/blob/a8847bd2906efff202fde10d776fddd20fd2ff57/src/ax/dsp/judge.ts#L148

AxJudge - Polymorphic evaluation engine that automatically selects the best strategy.

Example

const judge = new AxJudge(signature, { ai: teacherAI });

// Absolute mode (with ground truth)
const result1 = await judge.evaluate(
  { question: 'Capital of France?' },
  { answer: 'Paris' },
  { answer: 'Paris' }  // expected
);

// Relativistic mode (compare student vs teacher)
const result2 = await judge.evaluate(
  { question: 'Explain quantum computing' },
  studentResponse,
  teacherResponse
);

// Reference-free mode (no comparison data)
const result3 = await judge.evaluate(
  { question: 'Write a poem' },
  { poem: 'Roses are red...' }
);

Type Parameters

Type Parameter
IN extends AxGenIn
OUT extends AxGenOut

Constructors

Constructor

new AxJudge<IN, OUT>(signature: AxSignature<IN, OUT>, options: AxJudgeOptions): AxJudge<IN, OUT>;

Defined in: https://github.com/ax-llm/ax/blob/a8847bd2906efff202fde10d776fddd20fd2ff57/src/ax/dsp/judge.ts#L153

Parameters

ParameterType
signatureAxSignature<IN, OUT>
optionsAxJudgeOptions

Returns

AxJudge<IN, OUT>

Methods

evaluate()

evaluate(
   input: IN, 
   studentOutput: OUT, 
referenceOutput?: OUT): Promise<AxJudgeResult>;

Defined in: https://github.com/ax-llm/ax/blob/a8847bd2906efff202fde10d776fddd20fd2ff57/src/ax/dsp/judge.ts#L166

The main entry point. Automatically routes to the best strategy.

Parameters

ParameterType
inputIN
studentOutputOUT
referenceOutput?OUT

Returns

Promise<AxJudgeResult>


getSignature()

getSignature(): AxSignature<IN, OUT>;

Defined in: https://github.com/ax-llm/ax/blob/a8847bd2906efff202fde10d776fddd20fd2ff57/src/ax/dsp/judge.ts#L451

Get the signature being evaluated.

Returns

AxSignature<IN, OUT>


toMetricFn()

toMetricFn(): AxMetricFn;

Defined in: https://github.com/ax-llm/ax/blob/a8847bd2906efff202fde10d776fddd20fd2ff57/src/ax/dsp/judge.ts#L413

Convert this judge to a metric function for use with optimizers. Uses relativistic mode when teacher output is available as expected.

Returns

AxMetricFn