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

AxFluentFieldType

Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/dsp/sig.ts#L209

Type Parameters

Type ParameterDefault type
TType extends AxFieldType["type"]AxFieldType["type"]
TIsArray extends booleanfalse
TOptions extends readonly string[] | undefinedundefined
TIsOptional extends booleanfalse
TIsInternal extends booleanfalse
TFields extends | Record<string, | AxFluentFieldInfo | AxFluentFieldType> | undefinedundefined
TIsCached extends booleanfalse

Implements

Constructors

Constructor

new AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>(fieldType: object): AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>;

Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/dsp/sig.ts#L238

Parameters

ParameterType
fieldType{ description?: string; fields?: TFields; format?: string; isArray: TIsArray; isCached: TIsCached; isInternal: TIsInternal; isOptional: TIsOptional; itemDescription?: string; maximum?: number; maxLength?: number; minimum?: number; minLength?: number; options?: TOptions; pattern?: string; patternDescription?: string; type: TType; }
fieldType.description?string
fieldType.fields?TFields
fieldType.format?string
fieldType.isArrayTIsArray
fieldType.isCachedTIsCached
fieldType.isInternalTIsInternal
fieldType.isOptionalTIsOptional
fieldType.itemDescription?string
fieldType.maximum?number
fieldType.maxLength?number
fieldType.minimum?number
fieldType.minLength?number
fieldType.options?TOptions
fieldType.pattern?string
fieldType.patternDescription?string
fieldType.typeTType

Returns

AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>

Properties

PropertyModifierType
description?readonlystring
fields?readonlyany
format?readonlystring
isArrayreadonlyTIsArray
isCachedreadonlyTIsCached
isInternalreadonlyTIsInternal
isOptionalreadonlyTIsOptional
itemDescription?readonlystring
maximum?readonlynumber
maxLength?readonlynumber
minimum?readonlynumber
minLength?readonlynumber
options?readonlyTOptions
pattern?readonlystring
patternDescription?readonlystring
typereadonlyTType

Methods

array()

array(desc?: string): AxFluentFieldType<TType, true, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>;

Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/dsp/sig.ts#L289

Parameters

ParameterType
desc?string

Returns

AxFluentFieldType<TType, true, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>


cache()

cache(): AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, true>;

Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/dsp/sig.ts#L328

Mark this input field for caching. When contextCache is enabled, cached fields are rendered in a separate user message with cache: true, allowing them to be cached by the LLM provider.

Returns

AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, true>


date()

date(): AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>;

Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/dsp/sig.ts#L471

Set date format validation for strings

Returns

AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>


datetime()

datetime(): AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>;

Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/dsp/sig.ts#L492

Set datetime format validation for strings

Returns

AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>


email()

email(): AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>;

Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/dsp/sig.ts#L402

Set email format validation for strings

Returns

AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>


internal()

internal(): AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, true, TFields, TIsCached>;

Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/dsp/sig.ts#L308

Returns

AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, true, TFields, TIsCached>


max()

max(value: number): AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>;

Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/dsp/sig.ts#L374

Set maximum value for numbers or maximum length for strings

Parameters

ParameterType
valuenumber

Returns

AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>


min()

min(value: number): AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>;

Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/dsp/sig.ts#L346

Set minimum value for numbers or minimum length for strings

Parameters

ParameterType
valuenumber

Returns

AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>


optional()

optional(): AxFluentFieldType<TType, TIsArray, TOptions, true, TIsInternal, TFields, TIsCached>;

Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/dsp/sig.ts#L274

Returns

AxFluentFieldType<TType, TIsArray, TOptions, true, TIsInternal, TFields, TIsCached>


regex()

regex(pattern: string, description: string): AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>;

Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/dsp/sig.ts#L446

Set regex pattern validation for strings

Parameters

ParameterTypeDescription
patternstringRegular expression pattern to match
descriptionstringHuman-readable description of what the pattern validates (e.g., “Must be a valid username with only lowercase letters, numbers, and underscores”)

Returns

AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>


url()

url(): AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>;

Defined in: https://github.com/ax-llm/ax/blob/242cf18d21de9f9d58c7c82f53305f0605497473/src/ax/dsp/sig.ts#L423

Set URL/URI format validation for strings

Returns

AxFluentFieldType<TType, TIsArray, TOptions, TIsOptional, TIsInternal, TFields, TIsCached>