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

AxSignature

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

Type Parameters

Type ParameterDefault type
_TInput extends Record<string, any>Record<string, any>
_TOutput extends Record<string, any>Record<string, any>

Constructors

Constructor

new AxSignature<_TInput, _TOutput>(signature?: Readonly<
  | string
  | AxSignature<Record<string, any>, Record<string, any>>
| AxSignatureConfig>): AxSignature<_TInput, _TOutput>;

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

Deprecated

Use AxSignature.create() for better type safety instead of the constructor. This constructor will be removed in v15.0.0.

Migration timeline:

Example

// Instead of: new AxSignature('userInput:string -> responseText:string')
// Use: AxSignature.create('userInput:string -> responseText:string')

Parameters

ParameterType
signature?Readonly< | string | AxSignature<Record<string, any>, Record<string, any>> | AxSignatureConfig>

Returns

AxSignature<_TInput, _TOutput>

Methods

addInputField()

addInputField(field: Readonly<AxField>): void;

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

Parameters

ParameterType
fieldReadonly<AxField>

Returns

void


addOutputField()

addOutputField(field: Readonly<AxField>): void;

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

Parameters

ParameterType
fieldReadonly<AxField>

Returns

void


appendInputField()

appendInputField<K, T>(name: K, fieldType: T): AxSignature<_TInput & Record<K, InferFieldValueType<T>>, _TOutput>;

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

Type Parameters

Type Parameter
K extends string
T extends AxFieldType

Parameters

ParameterType
nameK
fieldTypeT

Returns

AxSignature<_TInput & Record<K, InferFieldValueType<T>>, _TOutput>


appendOutputField()

appendOutputField<K, T>(name: K, fieldType: T): AxSignature<_TInput, _TOutput & Record<K, InferFieldValueType<T>>>;

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

Type Parameters

Type Parameter
K extends string
T extends AxFieldType

Parameters

ParameterType
nameK
fieldTypeT

Returns

AxSignature<_TInput, _TOutput & Record<K, InferFieldValueType<T>>>


getDescription()

getDescription(): undefined | string;

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

Returns

undefined | string


getInputFields()

getInputFields(): readonly AxIField[];

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

Returns

readonly AxIField[]


getOutputFields()

getOutputFields(): readonly AxIField[];

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

Returns

readonly AxIField[]


hash()

hash(): string;

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

Returns

string


prependInputField()

prependInputField<K, T>(name: K, fieldType: T): AxSignature<Record<K, InferFieldValueType<T>> & _TInput, _TOutput>;

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

Type Parameters

Type Parameter
K extends string
T extends AxFieldType

Parameters

ParameterType
nameK
fieldTypeT

Returns

AxSignature<Record<K, InferFieldValueType<T>> & _TInput, _TOutput>


prependOutputField()

prependOutputField<K, T>(name: K, fieldType: T): AxSignature<_TInput, Record<K, InferFieldValueType<T>> & _TOutput>;

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

Type Parameters

Type Parameter
K extends string
T extends AxFieldType

Parameters

ParameterType
nameK
fieldTypeT

Returns

AxSignature<_TInput, Record<K, InferFieldValueType<T>> & _TOutput>


setDescription()

setDescription(desc: string): void;

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

Parameters

ParameterType
descstring

Returns

void


setInputFields()

setInputFields(fields: readonly AxField[]): void;

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

Parameters

ParameterType
fieldsreadonly AxField[]

Returns

void


setOutputFields()

setOutputFields(fields: readonly AxField[]): void;

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

Parameters

ParameterType
fieldsreadonly AxField[]

Returns

void


toJSON()

toJSON(): object;

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

Returns

object

NameType
descriptionundefined | string
idstring
inputFieldsAxIField[]
outputFieldsAxIField[]

toJSONSchema()

toJSONSchema(): AxFunctionJSONSchema;

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

Returns

AxFunctionJSONSchema


toString()

toString(): string;

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

Returns

string


validate()

validate(): boolean;

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

Returns

boolean


create()

static create<T>(signature: T): AxSignature<ParseSignature<T>["inputs"], ParseSignature<T>["outputs"]>;

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

Static factory method for type inference. Creates a typed AxSignature instance from a signature string.

Type Parameters

Type Parameter
T extends string

Parameters

ParameterType
signatureT

Returns

AxSignature<ParseSignature<T>["inputs"], ParseSignature<T>["outputs"]>