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

AxFlowTypedSubContextImpl

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

Typed implementation of the sub-context for parallel execution with full type safety

Type Parameters

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

Implements

Constructors

Constructor

new AxFlowTypedSubContextImpl<TNodes, TState>(nodeGenerators: Map<string, 
  | AxGen<AxGenIn, AxGenOut>
| AxProgram<AxGenIn, AxGenOut>>): AxFlowTypedSubContextImpl<TNodes, TState>;

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

Parameters

ParameterType
nodeGeneratorsMap<string, | AxGen<AxGenIn, AxGenOut> | AxProgram<AxGenIn, AxGenOut>>

Returns

AxFlowTypedSubContextImpl<TNodes, TState>

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/subContext.ts#L126

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]>>>

Implementation of

AxFlowTypedSubContext.execute


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/subContext.ts#L190

Parameters

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

Returns

Promise<AxFlowState>

Implementation of

AxFlowTypedSubContext.executeSteps


map()

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

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

Type Parameters

Type Parameter
TNewState extends AxFlowState

Parameters

ParameterType
transform(state: TState) => TNewState

Returns

AxFlowTypedSubContext<TNodes, TNewState>

Implementation of

AxFlowTypedSubContext.map