AxSignatureBuilder
Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/sig.ts#L72
Type Parameters
| Type Parameter | Default type |
|---|---|
_TInput extends Record<string, any> | object |
_TOutput extends Record<string, any> | object |
Constructors
Constructor
new AxSignatureBuilder<_TInput, _TOutput>(): AxSignatureBuilder<_TInput, _TOutput>;Returns
AxSignatureBuilder<_TInput, _TOutput>
Methods
addInputFields()
addInputFields(fields: readonly AxIField[]): AxSignatureBuilder<Record<string, any>, _TOutput>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/sig.ts#L218
Add pre-existing input fields (e.g., extracted from another signature). Type safety is lost for these fields since they are dynamically defined.
Parameters
| Parameter | Type |
|---|---|
fields | readonly AxIField[] |
Returns
AxSignatureBuilder<Record<string, any>, _TOutput>
addOutputFields()
addOutputFields(fields: readonly AxIField[]): AxSignatureBuilder<_TInput, Record<string, any>>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/sig.ts#L231
Add pre-existing output fields (e.g., extracted from another signature). Type safety is lost for these fields since they are dynamically defined.
Parameters
| Parameter | Type |
|---|---|
fields | readonly AxIField[] |
Returns
AxSignatureBuilder<_TInput, Record<string, any>>
build()
build(): AxSignature<_TInput, _TOutput>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/sig.ts#L266
Build the final AxSignature instance
Returns
AxSignature<_TInput, _TOutput>
description()
description(description: string): AxSignatureBuilder<_TInput, _TOutput>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/sig.ts#L244
Set the description for the signature
Parameters
| Parameter | Type | Description |
|---|---|---|
description | string | Description text |
Returns
AxSignatureBuilder<_TInput, _TOutput>
input()
Call Signature
input<K, T>(
name: K,
fieldInfo: T,
prepend?: boolean): AxSignatureBuilder<AddFieldToShape<_TInput, K, T, "input">, _TOutput>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/sig.ts#L102
Add an input field to the signature. Three shapes:
- Native fluent field —
.input('name', f.string()). Supports every LLM-optimized affordance (.cache(),.internal(), multimodal, etc.). - Per-field Standard Schema —
.input('name', z.string().min(3), { cache: true }). Pass any zod/valibot/arktype schema. Companionoptsadds ax-specific hints (cache,internal) that schema libraries don’t represent. - Whole-object Standard Schema —
.input(z.object({...}), { fields: { ctx: { cache: true } } }). Decomposed into per-key fields in declaration order.
Example
f()
.input(z.object({
context: z.string(),
question: z.string().describe('User question'),
}), { fields: { context: { cache: true } } })
.output('answer', f.string())
.build();Type Parameters
| Type Parameter |
|---|
K extends string |
T extends | AxFluentFieldInfo<any, any, any, any, any, any, any> | AxFluentFieldType<any, any, any, any, any, any, any> |
Parameters
| Parameter | Type |
|---|---|
name | K |
fieldInfo | T |
prepend? | boolean |
Returns
AxSignatureBuilder<AddFieldToShape<_TInput, K, T, "input">, _TOutput>
Call Signature
input<K, T>(
name: K,
schema: T,
opts?: AxFieldOptions): AxSignatureBuilder<_TInput & { [P in string]: InferOutput<T> }, _TOutput>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/sig.ts#L112
Add an input field to the signature. Three shapes:
- Native fluent field —
.input('name', f.string()). Supports every LLM-optimized affordance (.cache(),.internal(), multimodal, etc.). - Per-field Standard Schema —
.input('name', z.string().min(3), { cache: true }). Pass any zod/valibot/arktype schema. Companionoptsadds ax-specific hints (cache,internal) that schema libraries don’t represent. - Whole-object Standard Schema —
.input(z.object({...}), { fields: { ctx: { cache: true } } }). Decomposed into per-key fields in declaration order.
Example
f()
.input(z.object({
context: z.string(),
question: z.string().describe('User question'),
}), { fields: { context: { cache: true } } })
.output('answer', f.string())
.build();Type Parameters
| Type Parameter |
|---|
K extends string |
T extends StandardSchemaV1<unknown, unknown> |
Parameters
| Parameter | Type |
|---|---|
name | K |
schema | T |
opts? | AxFieldOptions |
Returns
AxSignatureBuilder<_TInput & { [P in string]: InferOutput<T> }, _TOutput>
Call Signature
input<T>(schema: T, opts?: object): AxSignatureBuilder<AsRecord<InferOutput<T>>, _TOutput>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/sig.ts#L120
Add an input field to the signature. Three shapes:
- Native fluent field —
.input('name', f.string()). Supports every LLM-optimized affordance (.cache(),.internal(), multimodal, etc.). - Per-field Standard Schema —
.input('name', z.string().min(3), { cache: true }). Pass any zod/valibot/arktype schema. Companionoptsadds ax-specific hints (cache,internal) that schema libraries don’t represent. - Whole-object Standard Schema —
.input(z.object({...}), { fields: { ctx: { cache: true } } }). Decomposed into per-key fields in declaration order.
Example
f()
.input(z.object({
context: z.string(),
question: z.string().describe('User question'),
}), { fields: { context: { cache: true } } })
.output('answer', f.string())
.build();Type Parameters
| Type Parameter |
|---|
T extends StandardSchemaV1<unknown, unknown> |
Parameters
| Parameter | Type |
|---|---|
schema | T |
opts? | { fields?: Record<string, AxFieldOptions>; } |
opts.fields? | Record<string, AxFieldOptions> |
Returns
AxSignatureBuilder<AsRecord<InferOutput<T>>, _TOutput>
output()
Call Signature
output<K, T>(
name: K,
fieldInfo: T,
prepend?: boolean): AxSignatureBuilder<_TInput, AddFieldToShape<_TOutput, K, T, "output">>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/sig.ts#L160
Add an output field to the signature. Same three shapes as AxSignatureBuilder.input.
Type Parameters
| Type Parameter |
|---|
K extends string |
T extends | AxFluentFieldInfo<any, any, any, any, any, any, any> | AxFluentFieldType<any, any, any, any, any, any, any> |
Parameters
| Parameter | Type |
|---|---|
name | K |
fieldInfo | T |
prepend? | boolean |
Returns
AxSignatureBuilder<_TInput, AddFieldToShape<_TOutput, K, T, "output">>
Call Signature
output<K, T>(
name: K,
schema: T,
opts?: AxFieldOptions): AxSignatureBuilder<_TInput, _TOutput & { [P in string]: InferOutput<T> }>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/sig.ts#L170
Add an output field to the signature. Same three shapes as AxSignatureBuilder.input.
Type Parameters
| Type Parameter |
|---|
K extends string |
T extends StandardSchemaV1<unknown, unknown> |
Parameters
| Parameter | Type |
|---|---|
name | K |
schema | T |
opts? | AxFieldOptions |
Returns
AxSignatureBuilder<_TInput, _TOutput & { [P in string]: InferOutput<T> }>
Call Signature
output<T>(schema: T, opts?: object): AxSignatureBuilder<_TInput, AsRecord<InferOutput<T>>>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/sig.ts#L178
Add an output field to the signature. Same three shapes as AxSignatureBuilder.input.
Type Parameters
| Type Parameter |
|---|
T extends StandardSchemaV1<unknown, unknown> |
Parameters
| Parameter | Type |
|---|---|
schema | T |
opts? | { fields?: Record<string, AxFieldOptions>; } |
opts.fields? | Record<string, AxFieldOptions> |
Returns
AxSignatureBuilder<_TInput, AsRecord<InferOutput<T>>>
useStructured()
useStructured(): AxSignatureBuilder<_TInput, _TOutput>;Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/sig.ts#L254
Enforce structured outputs (JSON) for this signature, even if fields are simple.
Returns
AxSignatureBuilder<_TInput, _TOutput>