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

AxFlowTypedSubContext

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/flow/types.ts#L78

Type Parameters

Type Parameter
TNodes extends Record<string, AxProgrammable<any, any>>
TState extends AxFlowState

Methods

execute()

execute<TNodeName, TAI>(
   nodeName: TNodeName, 
   mapping: (state: TState) => GetGenIn<TNodes[TNodeName]>, 
dynamicContext?: AxFlowDynamicContext<TAI>): AxFlowTypedSubContext<TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/flow/types.ts#L82

Type Parameters

Type Parameter
TNodeName extends string
TAI extends Readonly<AxAIService<unknown, unknown, string>>

Parameters

ParameterType
nodeNameTNodeName
mapping(state: TState) => GetGenIn<TNodes[TNodeName]>
dynamicContext?AxFlowDynamicContext<TAI>

Returns

AxFlowTypedSubContext<TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>


executeSteps()

executeSteps(initialState: TState, context: Readonly<{
  mainAi: AxAIService;
  mainOptions?: AxProgramForwardOptions<string>;
}>): Promise<AxFlowState>;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/flow/types.ts#L98

Parameters

ParameterType
initialStateTState
contextReadonly<{ mainAi: AxAIService; mainOptions?: AxProgramForwardOptions<string>; }>

Returns

Promise<AxFlowState>


map()

map<TNewState>(transform: (state: TState) => TNewState): AxFlowTypedSubContext<TNodes, TNewState>;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/flow/types.ts#L94

Type Parameters

Type Parameter
TNewState extends AxFlowState

Parameters

ParameterType
transform(state: TState) => TNewState

Returns

AxFlowTypedSubContext<TNodes, TNewState>