AxDefaultResultReranker
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/docs/reranker.ts#L11
Extends
Constructors
Constructor
new AxDefaultResultReranker(options?: Readonly<AxProgramForwardOptions<string>>): AxDefaultResultReranker;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/docs/reranker.ts#L15
Parameters
| Parameter | Type |
|---|---|
options? | Readonly<AxProgramForwardOptions<string>> |
Returns
AxDefaultResultReranker
Overrides
Methods
_forward1()
_forward1(
ai: Readonly<AxAIService>,
values:
| AxRerankerIn
| AxMessage<AxRerankerIn>[],
options: Readonly<AxProgramForwardOptions<any>>): AxGenStreamingOut<AxRerankerOut>;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/generate.ts#L1651
Parameters
| Parameter | Type |
|---|---|
ai | Readonly<AxAIService> |
values | | AxRerankerIn | AxMessage<AxRerankerIn>[] |
options | Readonly<AxProgramForwardOptions<any>> |
Returns
AxGenStreamingOut<AxRerankerOut>
Inherited from
addAssert()
addAssert(fn: (values: AxRerankerOut) =>
| undefined
| string
| boolean
| Promise<undefined | string | boolean>, message?: string): void;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/generate.ts#L261
Parameters
| Parameter | Type |
|---|---|
fn | (values: AxRerankerOut) => | undefined | string | boolean | Promise<undefined | string | boolean> |
message? | string |
Returns
void
Inherited from
addFieldProcessor()
addFieldProcessor<K>(fieldName: K, fn: (value: AxRerankerOut[K], context?: object) => unknown): void;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/generate.ts#L336
Type Parameters
| Type Parameter |
|---|
K extends "rankedItems" |
Parameters
| Parameter | Type |
|---|---|
fieldName | K |
fn | (value: AxRerankerOut[K], context?: object) => unknown |
Returns
void
Inherited from
addStreamingAssert()
addStreamingAssert(
fieldName: "rankedItems",
fn: (content: string, done?: boolean) => undefined | string | boolean,
message?: string): void;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/generate.ts#L265
Parameters
| Parameter | Type |
|---|---|
fieldName | "rankedItems" |
fn | (content: string, done?: boolean) => undefined | string | boolean |
message? | string |
Returns
void
Inherited from
addStreamingFieldProcessor()
addStreamingFieldProcessor<K>(fieldName: K, fn: (value: string, context?: object) => unknown): void;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/generate.ts#L322
Type Parameters
| Type Parameter |
|---|
K extends "rankedItems" |
Parameters
| Parameter | Type |
|---|---|
fieldName | K |
fn | (value: string, context?: object) => unknown |
Returns
void
Inherited from
AxGen.addStreamingFieldProcessor
applyOptimization()
applyOptimization(optimizedProgram: AxOptimizedProgram<AxRerankerOut>): void;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/program.ts#L307
Parameters
| Parameter | Type |
|---|---|
optimizedProgram | AxOptimizedProgram<AxRerankerOut> |
Returns
void
Inherited from
clone()
clone(): AxGen<AxRerankerIn, AxRerankerOut>;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/generate.ts#L150
Returns
AxGen<AxRerankerIn, AxRerankerOut>
Inherited from
forward()
forward<T>(
ai: T,
input: Readonly<AxRerankerIn>,
options?: Readonly<AxProgramForwardOptionsWithModels<T>>): Promise<AxRerankerOut>;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/docs/reranker.ts#L22
Executes the generator with the given AI service and input values.
This is the main entry point for running an AI generation. The execution pipeline:
- Validate - Check input values match the signature
- Render - Build the prompt from signature, examples, and inputs
- Call - Send the request to the AI service
- Parse - Extract structured outputs from the response
- Assert - Validate outputs and retry with error correction if needed
Type Parameters
| Type Parameter |
|---|
T extends Readonly<AxAIService<unknown, unknown, string>> |
Parameters
| Parameter | Type | Description |
|---|---|---|
ai | T | The AI service instance to use (created via ai() factory) |
input | Readonly<AxRerankerIn> | Input values matching the signature’s input fields, or an array of AxMessage objects for multi-turn conversations |
options? | Readonly<AxProgramForwardOptionsWithModels<T>> | Optional execution configuration |
Returns
Promise<AxRerankerOut>
Promise resolving to the output values matching the signature’s output fields
Throws
When input values don’t match the signature
Throws
When output parsing/validation fails after all retries
Throws
When the AI service request fails
Examples
const gen = ax('question: string -> answer: string');
const result = await gen.forward(ai, { question: 'What is 2+2?' });
console.log(result.answer); // "4"
const result = await gen.forward(ai, { question: 'Explain quantum computing' }, {
maxTokens: 2000,
temperature: 0.3,
stream: true
});
const mem = new AxMemory();
const chat = ax('message: string -> reply: string');
await chat.forward(ai, { message: 'Hi, my name is Alice' }, { mem });
const result = await chat.forward(ai, { message: 'What is my name?' }, { mem });
// result.reply will reference "Alice" from conversation history
const result = await gen.forward(ai, values, {
functions: [{
name: 'getWeather',
description: 'Get current weather for a city',
parameters: {
type: 'object',
properties: { city: { type: 'string', description: 'City name' } },
required: ['city']
},
func: async ({ city }) => fetchWeather(city)
}],
maxSteps: 5
});
Overrides
getId()
getId(): string;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/program.ts#L93
Returns
string
Inherited from
getInstruction()
getInstruction(): undefined | string;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/generate.ts#L217
Returns
undefined | string
Inherited from
getSignature()
getSignature(): AxSignature;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/program.ts#L66
Returns
Inherited from
getTraces()
getTraces(): AxProgramTrace<AxRerankerIn, AxRerankerOut>[];
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/program.ts#L148
Returns
AxProgramTrace<AxRerankerIn, AxRerankerOut>[]
Inherited from
getUsage()
getUsage(): AxModelUsage & object[];
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/program.ts#L162
Returns
AxModelUsage & object[]
Inherited from
namedPrograms()
namedPrograms(): object[];
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/program.ts#L276
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
agent.setId('qa');
console.log(agent.namedPrograms());
// [
// { id: 'qa.actor', signature: '... -> javascriptCode' },
// { id: 'qa.responder', signature: '... -> answer' },
// ]
Returns
object[]
Inherited from
register()
register(prog: Readonly<AxTunable<IN, OUT> & AxUsable>, name?: string): void;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/program.ts#L97
Parameters
| Parameter | Type |
|---|---|
prog | Readonly<AxTunable<IN, OUT> & AxUsable> |
name? | string |
Returns
void
Inherited from
resetUsage()
resetUsage(): void;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/program.ts#L172
Returns
void
Inherited from
setDemos()
setDemos(demos: readonly AxProgramDemos<AxRerankerIn, AxRerankerOut>[], options?: object): void;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/program.ts#L181
Parameters
| Parameter | Type |
|---|---|
demos | readonly AxProgramDemos<AxRerankerIn, AxRerankerOut>[] |
options? | { modelConfig?: Record<string, unknown>; } |
options.modelConfig? | Record<string, unknown> |
Returns
void
Inherited from
setDescription()
setDescription(description: string): void;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/program.ts#L84
Parameters
| Parameter | Type |
|---|---|
description | string |
Returns
void
Inherited from
setExamples()
setExamples(examples: Readonly<AxProgramExamples<AxRerankerIn, AxRerankerOut>>, options?: Readonly<AxSetExamplesOptions>): void;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/generate.ts#L2126
Parameters
| Parameter | Type |
|---|---|
examples | Readonly<AxProgramExamples<AxRerankerIn, AxRerankerOut>> |
options? | Readonly<AxSetExamplesOptions> |
Returns
void
Inherited from
setId()
setId(id: string): void;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/program.ts#L108
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
void
Inherited from
setInstruction()
setInstruction(instruction: string): void;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/generate.ts#L213
Parameters
| Parameter | Type |
|---|---|
instruction | string |
Returns
void
Inherited from
setSignature()
setSignature(signature:
| string
| Readonly<AxSignature<Record<string, any>, Record<string, any>>>
| Readonly<AxSignatureConfig>): void;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/program.ts#L70
Parameters
| Parameter | Type |
|---|---|
signature | | string | Readonly<AxSignature<Record<string, any>, Record<string, any>>> | Readonly<AxSignatureConfig> |
Returns
void
Inherited from
stop()
stop(): void;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/generate.ts#L205
Stops an in-flight generation. Causes forward() / streamingForward()
to throw AxAIServiceAbortedError.
Returns
void
Inherited from
streamingForward()
streamingForward<T>(
ai: T,
values:
| AxRerankerIn
| AxMessage<AxRerankerIn>[],
options?: Readonly<AxProgramStreamingForwardOptionsWithModels<T>>): AxGenStreamingOut<AxRerankerOut>;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/generate.ts#L2037
Type Parameters
| Type Parameter |
|---|
T extends Readonly<AxAIService<unknown, unknown, string>> |
Parameters
| Parameter | Type |
|---|---|
ai | T |
values | | AxRerankerIn | AxMessage<AxRerankerIn>[] |
options? | Readonly<AxProgramStreamingForwardOptionsWithModels<T>> |
Returns
AxGenStreamingOut<AxRerankerOut>
Inherited from
updateMeter()
updateMeter(meter?: Meter): void;
Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/generate.ts#L241
Parameters
| Parameter | Type |
|---|---|
meter? | Meter |
Returns
void