@ax-llm/ax 13.0.8 → 13.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +25 -28
- package/index.cjs.map +1 -1
- package/index.d.cts +57 -8
- package/index.d.ts +57 -8
- package/index.js +27 -30
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.cts
CHANGED
|
@@ -4332,7 +4332,7 @@ interface AxFlowBranchContext {
|
|
|
4332
4332
|
currentBranchValue?: unknown;
|
|
4333
4333
|
}
|
|
4334
4334
|
interface AxFlowExecutionStep {
|
|
4335
|
-
type: 'execute' | 'map' | 'merge' | 'parallel-map' | 'parallel';
|
|
4335
|
+
type: 'execute' | 'map' | 'merge' | 'parallel-map' | 'parallel' | 'derive';
|
|
4336
4336
|
nodeName?: string;
|
|
4337
4337
|
dependencies: string[];
|
|
4338
4338
|
produces: string[];
|
|
@@ -4391,10 +4391,34 @@ declare class AxFlowExecutionPlanner {
|
|
|
4391
4391
|
* @param mapTransform - Transformation function (for map steps)
|
|
4392
4392
|
* @param mergeOptions - Options for merge operations (result key, merge function)
|
|
4393
4393
|
*/
|
|
4394
|
-
addExecutionStep(stepFunction: AxFlowStepFunction, nodeName?: string, mapping?: (state: any) => any, stepType?: 'execute' | 'map' | 'merge' | 'parallel-map' | 'parallel', mapTransform?: (state: any) => any, mergeOptions?: {
|
|
4394
|
+
addExecutionStep(stepFunction: AxFlowStepFunction, nodeName?: string, mapping?: (state: any) => any, stepType?: 'execute' | 'map' | 'merge' | 'parallel-map' | 'parallel' | 'derive', mapTransform?: (state: any) => any, mergeOptions?: {
|
|
4395
4395
|
resultKey?: string;
|
|
4396
4396
|
mergeFunction?: (...args: any[]) => any;
|
|
4397
|
+
}, deriveOptions?: {
|
|
4398
|
+
inputFieldName: string;
|
|
4399
|
+
outputFieldName: string;
|
|
4400
|
+
batchSize?: number;
|
|
4397
4401
|
}): void;
|
|
4402
|
+
/**
|
|
4403
|
+
* Analyzes a step function to determine what fields it produces.
|
|
4404
|
+
*
|
|
4405
|
+
* This method analyzes the step function to understand what new fields
|
|
4406
|
+
* it adds to the state. It uses a mock state approach:
|
|
4407
|
+
* 1. Creates a mock state with sample data
|
|
4408
|
+
* 2. Runs the step function on the mock state
|
|
4409
|
+
* 3. Compares the result to see what fields were added
|
|
4410
|
+
*
|
|
4411
|
+
* @param stepFunction - The step function to analyze
|
|
4412
|
+
* @returns Array of field names that the step function produces
|
|
4413
|
+
*/
|
|
4414
|
+
private analyzeStepFunctionProduction;
|
|
4415
|
+
/**
|
|
4416
|
+
* Analyzes step function source code to determine what fields it produces.
|
|
4417
|
+
*
|
|
4418
|
+
* @param stepFunction - The step function to analyze
|
|
4419
|
+
* @returns Array of field names that the step function produces
|
|
4420
|
+
*/
|
|
4421
|
+
private analyzeStepFunctionSource;
|
|
4398
4422
|
/**
|
|
4399
4423
|
* Analyzes a map transformation function to determine what fields it produces.
|
|
4400
4424
|
*
|
|
@@ -4551,7 +4575,7 @@ declare class AxFlowExecutionPlanner {
|
|
|
4551
4575
|
* providing compile-time type safety and superior IntelliSense.
|
|
4552
4576
|
*
|
|
4553
4577
|
* @example
|
|
4554
|
-
* ```
|
|
4578
|
+
* ```
|
|
4555
4579
|
* const flow = new AxFlow<{ topic: string }, { finalAnswer: string }>()
|
|
4556
4580
|
* .node('summarizer', 'text:string -> summary:string')
|
|
4557
4581
|
* .node('critic', 'summary:string -> critique:string')
|
|
@@ -4656,7 +4680,7 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4656
4680
|
* @returns New AxFlow instance with updated TNodes type
|
|
4657
4681
|
*
|
|
4658
4682
|
* @example
|
|
4659
|
-
* ```
|
|
4683
|
+
* ```
|
|
4660
4684
|
* flow.node('summarizer', 'text:string -> summary:string')
|
|
4661
4685
|
* flow.node('analyzer', 'text:string -> analysis:string, confidence:number', { debug: true })
|
|
4662
4686
|
* ```
|
|
@@ -4675,7 +4699,7 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4675
4699
|
* @returns New AxFlow instance with updated TNodes type
|
|
4676
4700
|
*
|
|
4677
4701
|
* @example
|
|
4678
|
-
* ```
|
|
4702
|
+
* ```
|
|
4679
4703
|
* const sig = new AxSignature('text:string -> summary:string')
|
|
4680
4704
|
* flow.node('summarizer', sig, { temperature: 0.1 })
|
|
4681
4705
|
* ```
|
|
@@ -4693,7 +4717,7 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4693
4717
|
* @returns New AxFlow instance with updated TNodes type
|
|
4694
4718
|
*
|
|
4695
4719
|
* @example
|
|
4696
|
-
* ```
|
|
4720
|
+
* ```
|
|
4697
4721
|
* class CustomProgram extends AxProgram<{ input: string }, { output: string }> {
|
|
4698
4722
|
* async forward(ai, values) { return { output: values.input.toUpperCase() } }
|
|
4699
4723
|
* }
|
|
@@ -4739,7 +4763,7 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4739
4763
|
* @returns New AxFlow instance with updated TState type
|
|
4740
4764
|
*
|
|
4741
4765
|
* @example
|
|
4742
|
-
* ```
|
|
4766
|
+
* ```
|
|
4743
4767
|
* flow.map(state => ({ ...state, processedText: state.text.toLowerCase() }))
|
|
4744
4768
|
* ```
|
|
4745
4769
|
*/
|
|
@@ -4754,7 +4778,7 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4754
4778
|
* @returns New AxFlow instance with updated TState type
|
|
4755
4779
|
*
|
|
4756
4780
|
* @example
|
|
4757
|
-
* ```
|
|
4781
|
+
* ```
|
|
4758
4782
|
* // Parallel map with multiple transforms
|
|
4759
4783
|
* flow.map([
|
|
4760
4784
|
* state => ({ ...state, result1: processA(state.data) }),
|
|
@@ -4975,6 +4999,31 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4975
4999
|
* Short alias for endWhile()
|
|
4976
5000
|
*/
|
|
4977
5001
|
end(): this;
|
|
5002
|
+
/**
|
|
5003
|
+
* Derives a new field from an existing field by applying a transform function.
|
|
5004
|
+
*
|
|
5005
|
+
* If the input field contains an array, the transform function is applied to each
|
|
5006
|
+
* array element in parallel with batch size control. If the input field contains
|
|
5007
|
+
* a scalar value, the transform function is applied directly.
|
|
5008
|
+
*
|
|
5009
|
+
* @param outputFieldName - Name of the field to store the result
|
|
5010
|
+
* @param inputFieldName - Name of the existing field to transform
|
|
5011
|
+
* @param transformFn - Function to apply to each element (for arrays) or the value directly (for scalars)
|
|
5012
|
+
* @param options - Options including batch size for parallel processing
|
|
5013
|
+
* @returns this (for chaining)
|
|
5014
|
+
*
|
|
5015
|
+
* @example
|
|
5016
|
+
* ```typescript
|
|
5017
|
+
* // Parallel processing of array items
|
|
5018
|
+
* flow.derive('processedItems', 'items', (item, index) => processItem(item), { batchSize: 5 })
|
|
5019
|
+
*
|
|
5020
|
+
* // Direct transformation of scalar value
|
|
5021
|
+
* flow.derive('upperText', 'text', (text) => text.toUpperCase())
|
|
5022
|
+
* ```
|
|
5023
|
+
*/
|
|
5024
|
+
derive<T>(outputFieldName: string, inputFieldName: string, transformFn: (value: any, index?: number, state?: TState) => T, options?: {
|
|
5025
|
+
batchSize?: number;
|
|
5026
|
+
}): this;
|
|
4978
5027
|
/**
|
|
4979
5028
|
* Gets execution plan information for debugging automatic parallelization
|
|
4980
5029
|
*
|
package/index.d.ts
CHANGED
|
@@ -4332,7 +4332,7 @@ interface AxFlowBranchContext {
|
|
|
4332
4332
|
currentBranchValue?: unknown;
|
|
4333
4333
|
}
|
|
4334
4334
|
interface AxFlowExecutionStep {
|
|
4335
|
-
type: 'execute' | 'map' | 'merge' | 'parallel-map' | 'parallel';
|
|
4335
|
+
type: 'execute' | 'map' | 'merge' | 'parallel-map' | 'parallel' | 'derive';
|
|
4336
4336
|
nodeName?: string;
|
|
4337
4337
|
dependencies: string[];
|
|
4338
4338
|
produces: string[];
|
|
@@ -4391,10 +4391,34 @@ declare class AxFlowExecutionPlanner {
|
|
|
4391
4391
|
* @param mapTransform - Transformation function (for map steps)
|
|
4392
4392
|
* @param mergeOptions - Options for merge operations (result key, merge function)
|
|
4393
4393
|
*/
|
|
4394
|
-
addExecutionStep(stepFunction: AxFlowStepFunction, nodeName?: string, mapping?: (state: any) => any, stepType?: 'execute' | 'map' | 'merge' | 'parallel-map' | 'parallel', mapTransform?: (state: any) => any, mergeOptions?: {
|
|
4394
|
+
addExecutionStep(stepFunction: AxFlowStepFunction, nodeName?: string, mapping?: (state: any) => any, stepType?: 'execute' | 'map' | 'merge' | 'parallel-map' | 'parallel' | 'derive', mapTransform?: (state: any) => any, mergeOptions?: {
|
|
4395
4395
|
resultKey?: string;
|
|
4396
4396
|
mergeFunction?: (...args: any[]) => any;
|
|
4397
|
+
}, deriveOptions?: {
|
|
4398
|
+
inputFieldName: string;
|
|
4399
|
+
outputFieldName: string;
|
|
4400
|
+
batchSize?: number;
|
|
4397
4401
|
}): void;
|
|
4402
|
+
/**
|
|
4403
|
+
* Analyzes a step function to determine what fields it produces.
|
|
4404
|
+
*
|
|
4405
|
+
* This method analyzes the step function to understand what new fields
|
|
4406
|
+
* it adds to the state. It uses a mock state approach:
|
|
4407
|
+
* 1. Creates a mock state with sample data
|
|
4408
|
+
* 2. Runs the step function on the mock state
|
|
4409
|
+
* 3. Compares the result to see what fields were added
|
|
4410
|
+
*
|
|
4411
|
+
* @param stepFunction - The step function to analyze
|
|
4412
|
+
* @returns Array of field names that the step function produces
|
|
4413
|
+
*/
|
|
4414
|
+
private analyzeStepFunctionProduction;
|
|
4415
|
+
/**
|
|
4416
|
+
* Analyzes step function source code to determine what fields it produces.
|
|
4417
|
+
*
|
|
4418
|
+
* @param stepFunction - The step function to analyze
|
|
4419
|
+
* @returns Array of field names that the step function produces
|
|
4420
|
+
*/
|
|
4421
|
+
private analyzeStepFunctionSource;
|
|
4398
4422
|
/**
|
|
4399
4423
|
* Analyzes a map transformation function to determine what fields it produces.
|
|
4400
4424
|
*
|
|
@@ -4551,7 +4575,7 @@ declare class AxFlowExecutionPlanner {
|
|
|
4551
4575
|
* providing compile-time type safety and superior IntelliSense.
|
|
4552
4576
|
*
|
|
4553
4577
|
* @example
|
|
4554
|
-
* ```
|
|
4578
|
+
* ```
|
|
4555
4579
|
* const flow = new AxFlow<{ topic: string }, { finalAnswer: string }>()
|
|
4556
4580
|
* .node('summarizer', 'text:string -> summary:string')
|
|
4557
4581
|
* .node('critic', 'summary:string -> critique:string')
|
|
@@ -4656,7 +4680,7 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4656
4680
|
* @returns New AxFlow instance with updated TNodes type
|
|
4657
4681
|
*
|
|
4658
4682
|
* @example
|
|
4659
|
-
* ```
|
|
4683
|
+
* ```
|
|
4660
4684
|
* flow.node('summarizer', 'text:string -> summary:string')
|
|
4661
4685
|
* flow.node('analyzer', 'text:string -> analysis:string, confidence:number', { debug: true })
|
|
4662
4686
|
* ```
|
|
@@ -4675,7 +4699,7 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4675
4699
|
* @returns New AxFlow instance with updated TNodes type
|
|
4676
4700
|
*
|
|
4677
4701
|
* @example
|
|
4678
|
-
* ```
|
|
4702
|
+
* ```
|
|
4679
4703
|
* const sig = new AxSignature('text:string -> summary:string')
|
|
4680
4704
|
* flow.node('summarizer', sig, { temperature: 0.1 })
|
|
4681
4705
|
* ```
|
|
@@ -4693,7 +4717,7 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4693
4717
|
* @returns New AxFlow instance with updated TNodes type
|
|
4694
4718
|
*
|
|
4695
4719
|
* @example
|
|
4696
|
-
* ```
|
|
4720
|
+
* ```
|
|
4697
4721
|
* class CustomProgram extends AxProgram<{ input: string }, { output: string }> {
|
|
4698
4722
|
* async forward(ai, values) { return { output: values.input.toUpperCase() } }
|
|
4699
4723
|
* }
|
|
@@ -4739,7 +4763,7 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4739
4763
|
* @returns New AxFlow instance with updated TState type
|
|
4740
4764
|
*
|
|
4741
4765
|
* @example
|
|
4742
|
-
* ```
|
|
4766
|
+
* ```
|
|
4743
4767
|
* flow.map(state => ({ ...state, processedText: state.text.toLowerCase() }))
|
|
4744
4768
|
* ```
|
|
4745
4769
|
*/
|
|
@@ -4754,7 +4778,7 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4754
4778
|
* @returns New AxFlow instance with updated TState type
|
|
4755
4779
|
*
|
|
4756
4780
|
* @example
|
|
4757
|
-
* ```
|
|
4781
|
+
* ```
|
|
4758
4782
|
* // Parallel map with multiple transforms
|
|
4759
4783
|
* flow.map([
|
|
4760
4784
|
* state => ({ ...state, result1: processA(state.data) }),
|
|
@@ -4975,6 +4999,31 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
4975
4999
|
* Short alias for endWhile()
|
|
4976
5000
|
*/
|
|
4977
5001
|
end(): this;
|
|
5002
|
+
/**
|
|
5003
|
+
* Derives a new field from an existing field by applying a transform function.
|
|
5004
|
+
*
|
|
5005
|
+
* If the input field contains an array, the transform function is applied to each
|
|
5006
|
+
* array element in parallel with batch size control. If the input field contains
|
|
5007
|
+
* a scalar value, the transform function is applied directly.
|
|
5008
|
+
*
|
|
5009
|
+
* @param outputFieldName - Name of the field to store the result
|
|
5010
|
+
* @param inputFieldName - Name of the existing field to transform
|
|
5011
|
+
* @param transformFn - Function to apply to each element (for arrays) or the value directly (for scalars)
|
|
5012
|
+
* @param options - Options including batch size for parallel processing
|
|
5013
|
+
* @returns this (for chaining)
|
|
5014
|
+
*
|
|
5015
|
+
* @example
|
|
5016
|
+
* ```typescript
|
|
5017
|
+
* // Parallel processing of array items
|
|
5018
|
+
* flow.derive('processedItems', 'items', (item, index) => processItem(item), { batchSize: 5 })
|
|
5019
|
+
*
|
|
5020
|
+
* // Direct transformation of scalar value
|
|
5021
|
+
* flow.derive('upperText', 'text', (text) => text.toUpperCase())
|
|
5022
|
+
* ```
|
|
5023
|
+
*/
|
|
5024
|
+
derive<T>(outputFieldName: string, inputFieldName: string, transformFn: (value: any, index?: number, state?: TState) => T, options?: {
|
|
5025
|
+
batchSize?: number;
|
|
5026
|
+
}): this;
|
|
4978
5027
|
/**
|
|
4979
5028
|
* Gets execution plan information for debugging automatic parallelization
|
|
4980
5029
|
*
|