@ax-llm/ax 11.0.60 → 11.0.61
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 +24 -2
- package/index.cjs.map +1 -1
- package/index.d.cts +21 -17
- package/index.d.ts +21 -17
- package/index.js +24 -2
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.cts
CHANGED
|
@@ -2244,12 +2244,12 @@ type AxGenIn = {
|
|
|
2244
2244
|
[key: string]: AxFieldValue;
|
|
2245
2245
|
};
|
|
2246
2246
|
type AxGenOut = Record<string, AxFieldValue>;
|
|
2247
|
-
type AxMessage = {
|
|
2247
|
+
type AxMessage<IN extends AxGenIn> = {
|
|
2248
2248
|
role: 'user';
|
|
2249
|
-
values:
|
|
2249
|
+
values: IN;
|
|
2250
2250
|
} | {
|
|
2251
2251
|
role: 'assistant';
|
|
2252
|
-
values:
|
|
2252
|
+
values: IN;
|
|
2253
2253
|
};
|
|
2254
2254
|
|
|
2255
2255
|
type Writeable<T> = {
|
|
@@ -2271,7 +2271,7 @@ declare class AxPromptTemplate {
|
|
|
2271
2271
|
private readonly thoughtFieldName;
|
|
2272
2272
|
private readonly functions?;
|
|
2273
2273
|
constructor(sig: Readonly<AxSignature>, options?: Readonly<AxPromptTemplateOptions>, fieldTemplates?: Record<string, AxFieldTemplateFn>);
|
|
2274
|
-
render: <T extends AxGenIn>(values: T | ReadonlyArray<AxMessage
|
|
2274
|
+
render: <T extends AxGenIn>(values: T | ReadonlyArray<AxMessage<T>>, // Allow T (AxGenIn) or array of AxMessages
|
|
2275
2275
|
{ examples, demos, }: Readonly<{
|
|
2276
2276
|
skipSystemPrompt?: boolean;
|
|
2277
2277
|
examples?: Record<string, AxFieldValue>[];
|
|
@@ -2364,7 +2364,7 @@ type AxProgramUsage = AxChatResponse['modelUsage'] & {
|
|
|
2364
2364
|
interface AxProgramWithSignatureOptions {
|
|
2365
2365
|
description?: string;
|
|
2366
2366
|
}
|
|
2367
|
-
declare class AxProgramWithSignature<IN extends AxGenIn
|
|
2367
|
+
declare class AxProgramWithSignature<IN extends AxGenIn, OUT extends AxGenOut> implements AxTunable, AxUsable {
|
|
2368
2368
|
protected signature: AxSignature;
|
|
2369
2369
|
protected sigHash: string;
|
|
2370
2370
|
protected examples?: Record<string, AxFieldValue>[];
|
|
@@ -2377,8 +2377,8 @@ declare class AxProgramWithSignature<IN extends AxGenIn | ReadonlyArray<AxMessag
|
|
|
2377
2377
|
constructor(signature: Readonly<AxSignature | string>, options?: Readonly<AxProgramWithSignatureOptions>);
|
|
2378
2378
|
getSignature(): AxSignature;
|
|
2379
2379
|
register(prog: Readonly<AxTunable & AxUsable>): void;
|
|
2380
|
-
forward(_ai: Readonly<AxAIService>, _values: IN, _options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
|
|
2381
|
-
streamingForward(_ai: Readonly<AxAIService>, _values: IN, _options?: Readonly<AxProgramStreamingForwardOptions>): AxGenStreamingOut<OUT>;
|
|
2380
|
+
forward(_ai: Readonly<AxAIService>, _values: IN | AxMessage<IN>[], _options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
|
|
2381
|
+
streamingForward(_ai: Readonly<AxAIService>, _values: IN | AxMessage<IN>[], _options?: Readonly<AxProgramStreamingForwardOptions>): AxGenStreamingOut<OUT>;
|
|
2382
2382
|
setId(id: string): void;
|
|
2383
2383
|
setParentId(parentId: string): void;
|
|
2384
2384
|
setExamples(examples: Readonly<AxProgramExamples>, options?: Readonly<AxSetExamplesOptions>): void;
|
|
@@ -2395,8 +2395,8 @@ declare class AxProgram<IN extends AxGenIn, OUT extends AxGenOut> implements AxT
|
|
|
2395
2395
|
private children;
|
|
2396
2396
|
constructor();
|
|
2397
2397
|
register(prog: Readonly<AxTunable & AxUsable>): void;
|
|
2398
|
-
forward(_ai: Readonly<AxAIService>, _values: IN, _options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
|
|
2399
|
-
streamingForward(_ai: Readonly<AxAIService>, _values: IN, _options?: Readonly<AxProgramStreamingForwardOptions>): AxGenStreamingOut<OUT>;
|
|
2398
|
+
forward(_ai: Readonly<AxAIService>, _values: IN | AxMessage<IN>[], _options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
|
|
2399
|
+
streamingForward(_ai: Readonly<AxAIService>, _values: IN | AxMessage<IN>[], _options?: Readonly<AxProgramStreamingForwardOptions>): AxGenStreamingOut<OUT>;
|
|
2400
2400
|
setId(id: string): void;
|
|
2401
2401
|
setParentId(parentId: string): void;
|
|
2402
2402
|
setExamples(examples: Readonly<AxProgramExamples>, options?: Readonly<AxSetExamplesOptions>): void;
|
|
@@ -2465,8 +2465,8 @@ declare class AxAgent<IN extends AxGenIn, OUT extends AxGenOut = AxGenOut> imple
|
|
|
2465
2465
|
* Initializes the agent's execution context, processing child agents and their functions.
|
|
2466
2466
|
*/
|
|
2467
2467
|
private init;
|
|
2468
|
-
forward(parentAi: Readonly<AxAIService>, values: IN, options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
|
|
2469
|
-
streamingForward(parentAi: Readonly<AxAIService>, values: IN, options?: Readonly<AxProgramStreamingForwardOptions>): AxGenStreamingOut<OUT>;
|
|
2468
|
+
forward(parentAi: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
|
|
2469
|
+
streamingForward(parentAi: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramStreamingForwardOptions>): AxGenStreamingOut<OUT>;
|
|
2470
2470
|
/**
|
|
2471
2471
|
* Updates the agent's description.
|
|
2472
2472
|
* This updates both the stored description and the function's description.
|
|
@@ -2840,7 +2840,7 @@ interface AxStreamingEvent<T> {
|
|
|
2840
2840
|
functions?: AxChatResponseFunctionCall[];
|
|
2841
2841
|
};
|
|
2842
2842
|
}
|
|
2843
|
-
declare class AxGen<IN extends AxGenIn
|
|
2843
|
+
declare class AxGen<IN extends AxGenIn, OUT extends AxGenerateResult<AxGenOut> = AxGenerateResult<AxGenOut>> extends AxProgramWithSignature<IN, OUT> {
|
|
2844
2844
|
private promptTemplate;
|
|
2845
2845
|
private asserts;
|
|
2846
2846
|
private streamingAsserts;
|
|
@@ -2865,12 +2865,12 @@ declare class AxGen<IN extends AxGenIn | ReadonlyArray<AxMessage> = AxGenIn | Re
|
|
|
2865
2865
|
private processResponse;
|
|
2866
2866
|
private _forward2;
|
|
2867
2867
|
private shouldContinueSteps;
|
|
2868
|
-
_forward1(ai: Readonly<AxAIService>, values: IN, options: Readonly<AxProgramForwardOptions>): AsyncGenerator<{
|
|
2868
|
+
_forward1(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options: Readonly<AxProgramForwardOptions>): AsyncGenerator<{
|
|
2869
2869
|
version: number;
|
|
2870
2870
|
delta: Partial<OUT>;
|
|
2871
2871
|
}, void, unknown>;
|
|
2872
|
-
forward(ai: Readonly<AxAIService>, values: IN, options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
|
|
2873
|
-
streamingForward(ai: Readonly<AxAIService>, values: IN, options?: Readonly<AxProgramStreamingForwardOptions>): AsyncGenerator<{
|
|
2872
|
+
forward(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
|
|
2873
|
+
streamingForward(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramStreamingForwardOptions>): AsyncGenerator<{
|
|
2874
2874
|
version: number;
|
|
2875
2875
|
delta: Partial<OUT>;
|
|
2876
2876
|
}, void, unknown>;
|
|
@@ -3690,9 +3690,13 @@ declare class AxRAG extends AxChainOfThought<{
|
|
|
3690
3690
|
constructor(queryFn: (query: string) => Promise<string>, options: Readonly<AxProgramForwardOptions & {
|
|
3691
3691
|
maxHops?: number;
|
|
3692
3692
|
}>);
|
|
3693
|
-
forward(ai: Readonly<AxAIService>,
|
|
3693
|
+
forward(ai: Readonly<AxAIService>, values: {
|
|
3694
|
+
context: string[];
|
|
3694
3695
|
question: string;
|
|
3695
|
-
}
|
|
3696
|
+
} | AxMessage<{
|
|
3697
|
+
context: string[];
|
|
3698
|
+
question: string;
|
|
3699
|
+
}>[], options?: Readonly<AxProgramForwardOptions>): Promise<{
|
|
3696
3700
|
answer: string;
|
|
3697
3701
|
}>;
|
|
3698
3702
|
}
|
package/index.d.ts
CHANGED
|
@@ -2244,12 +2244,12 @@ type AxGenIn = {
|
|
|
2244
2244
|
[key: string]: AxFieldValue;
|
|
2245
2245
|
};
|
|
2246
2246
|
type AxGenOut = Record<string, AxFieldValue>;
|
|
2247
|
-
type AxMessage = {
|
|
2247
|
+
type AxMessage<IN extends AxGenIn> = {
|
|
2248
2248
|
role: 'user';
|
|
2249
|
-
values:
|
|
2249
|
+
values: IN;
|
|
2250
2250
|
} | {
|
|
2251
2251
|
role: 'assistant';
|
|
2252
|
-
values:
|
|
2252
|
+
values: IN;
|
|
2253
2253
|
};
|
|
2254
2254
|
|
|
2255
2255
|
type Writeable<T> = {
|
|
@@ -2271,7 +2271,7 @@ declare class AxPromptTemplate {
|
|
|
2271
2271
|
private readonly thoughtFieldName;
|
|
2272
2272
|
private readonly functions?;
|
|
2273
2273
|
constructor(sig: Readonly<AxSignature>, options?: Readonly<AxPromptTemplateOptions>, fieldTemplates?: Record<string, AxFieldTemplateFn>);
|
|
2274
|
-
render: <T extends AxGenIn>(values: T | ReadonlyArray<AxMessage
|
|
2274
|
+
render: <T extends AxGenIn>(values: T | ReadonlyArray<AxMessage<T>>, // Allow T (AxGenIn) or array of AxMessages
|
|
2275
2275
|
{ examples, demos, }: Readonly<{
|
|
2276
2276
|
skipSystemPrompt?: boolean;
|
|
2277
2277
|
examples?: Record<string, AxFieldValue>[];
|
|
@@ -2364,7 +2364,7 @@ type AxProgramUsage = AxChatResponse['modelUsage'] & {
|
|
|
2364
2364
|
interface AxProgramWithSignatureOptions {
|
|
2365
2365
|
description?: string;
|
|
2366
2366
|
}
|
|
2367
|
-
declare class AxProgramWithSignature<IN extends AxGenIn
|
|
2367
|
+
declare class AxProgramWithSignature<IN extends AxGenIn, OUT extends AxGenOut> implements AxTunable, AxUsable {
|
|
2368
2368
|
protected signature: AxSignature;
|
|
2369
2369
|
protected sigHash: string;
|
|
2370
2370
|
protected examples?: Record<string, AxFieldValue>[];
|
|
@@ -2377,8 +2377,8 @@ declare class AxProgramWithSignature<IN extends AxGenIn | ReadonlyArray<AxMessag
|
|
|
2377
2377
|
constructor(signature: Readonly<AxSignature | string>, options?: Readonly<AxProgramWithSignatureOptions>);
|
|
2378
2378
|
getSignature(): AxSignature;
|
|
2379
2379
|
register(prog: Readonly<AxTunable & AxUsable>): void;
|
|
2380
|
-
forward(_ai: Readonly<AxAIService>, _values: IN, _options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
|
|
2381
|
-
streamingForward(_ai: Readonly<AxAIService>, _values: IN, _options?: Readonly<AxProgramStreamingForwardOptions>): AxGenStreamingOut<OUT>;
|
|
2380
|
+
forward(_ai: Readonly<AxAIService>, _values: IN | AxMessage<IN>[], _options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
|
|
2381
|
+
streamingForward(_ai: Readonly<AxAIService>, _values: IN | AxMessage<IN>[], _options?: Readonly<AxProgramStreamingForwardOptions>): AxGenStreamingOut<OUT>;
|
|
2382
2382
|
setId(id: string): void;
|
|
2383
2383
|
setParentId(parentId: string): void;
|
|
2384
2384
|
setExamples(examples: Readonly<AxProgramExamples>, options?: Readonly<AxSetExamplesOptions>): void;
|
|
@@ -2395,8 +2395,8 @@ declare class AxProgram<IN extends AxGenIn, OUT extends AxGenOut> implements AxT
|
|
|
2395
2395
|
private children;
|
|
2396
2396
|
constructor();
|
|
2397
2397
|
register(prog: Readonly<AxTunable & AxUsable>): void;
|
|
2398
|
-
forward(_ai: Readonly<AxAIService>, _values: IN, _options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
|
|
2399
|
-
streamingForward(_ai: Readonly<AxAIService>, _values: IN, _options?: Readonly<AxProgramStreamingForwardOptions>): AxGenStreamingOut<OUT>;
|
|
2398
|
+
forward(_ai: Readonly<AxAIService>, _values: IN | AxMessage<IN>[], _options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
|
|
2399
|
+
streamingForward(_ai: Readonly<AxAIService>, _values: IN | AxMessage<IN>[], _options?: Readonly<AxProgramStreamingForwardOptions>): AxGenStreamingOut<OUT>;
|
|
2400
2400
|
setId(id: string): void;
|
|
2401
2401
|
setParentId(parentId: string): void;
|
|
2402
2402
|
setExamples(examples: Readonly<AxProgramExamples>, options?: Readonly<AxSetExamplesOptions>): void;
|
|
@@ -2465,8 +2465,8 @@ declare class AxAgent<IN extends AxGenIn, OUT extends AxGenOut = AxGenOut> imple
|
|
|
2465
2465
|
* Initializes the agent's execution context, processing child agents and their functions.
|
|
2466
2466
|
*/
|
|
2467
2467
|
private init;
|
|
2468
|
-
forward(parentAi: Readonly<AxAIService>, values: IN, options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
|
|
2469
|
-
streamingForward(parentAi: Readonly<AxAIService>, values: IN, options?: Readonly<AxProgramStreamingForwardOptions>): AxGenStreamingOut<OUT>;
|
|
2468
|
+
forward(parentAi: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
|
|
2469
|
+
streamingForward(parentAi: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramStreamingForwardOptions>): AxGenStreamingOut<OUT>;
|
|
2470
2470
|
/**
|
|
2471
2471
|
* Updates the agent's description.
|
|
2472
2472
|
* This updates both the stored description and the function's description.
|
|
@@ -2840,7 +2840,7 @@ interface AxStreamingEvent<T> {
|
|
|
2840
2840
|
functions?: AxChatResponseFunctionCall[];
|
|
2841
2841
|
};
|
|
2842
2842
|
}
|
|
2843
|
-
declare class AxGen<IN extends AxGenIn
|
|
2843
|
+
declare class AxGen<IN extends AxGenIn, OUT extends AxGenerateResult<AxGenOut> = AxGenerateResult<AxGenOut>> extends AxProgramWithSignature<IN, OUT> {
|
|
2844
2844
|
private promptTemplate;
|
|
2845
2845
|
private asserts;
|
|
2846
2846
|
private streamingAsserts;
|
|
@@ -2865,12 +2865,12 @@ declare class AxGen<IN extends AxGenIn | ReadonlyArray<AxMessage> = AxGenIn | Re
|
|
|
2865
2865
|
private processResponse;
|
|
2866
2866
|
private _forward2;
|
|
2867
2867
|
private shouldContinueSteps;
|
|
2868
|
-
_forward1(ai: Readonly<AxAIService>, values: IN, options: Readonly<AxProgramForwardOptions>): AsyncGenerator<{
|
|
2868
|
+
_forward1(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options: Readonly<AxProgramForwardOptions>): AsyncGenerator<{
|
|
2869
2869
|
version: number;
|
|
2870
2870
|
delta: Partial<OUT>;
|
|
2871
2871
|
}, void, unknown>;
|
|
2872
|
-
forward(ai: Readonly<AxAIService>, values: IN, options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
|
|
2873
|
-
streamingForward(ai: Readonly<AxAIService>, values: IN, options?: Readonly<AxProgramStreamingForwardOptions>): AsyncGenerator<{
|
|
2872
|
+
forward(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
|
|
2873
|
+
streamingForward(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramStreamingForwardOptions>): AsyncGenerator<{
|
|
2874
2874
|
version: number;
|
|
2875
2875
|
delta: Partial<OUT>;
|
|
2876
2876
|
}, void, unknown>;
|
|
@@ -3690,9 +3690,13 @@ declare class AxRAG extends AxChainOfThought<{
|
|
|
3690
3690
|
constructor(queryFn: (query: string) => Promise<string>, options: Readonly<AxProgramForwardOptions & {
|
|
3691
3691
|
maxHops?: number;
|
|
3692
3692
|
}>);
|
|
3693
|
-
forward(ai: Readonly<AxAIService>,
|
|
3693
|
+
forward(ai: Readonly<AxAIService>, values: {
|
|
3694
|
+
context: string[];
|
|
3694
3695
|
question: string;
|
|
3695
|
-
}
|
|
3696
|
+
} | AxMessage<{
|
|
3697
|
+
context: string[];
|
|
3698
|
+
question: string;
|
|
3699
|
+
}>[], options?: Readonly<AxProgramForwardOptions>): Promise<{
|
|
3696
3700
|
answer: string;
|
|
3697
3701
|
}>;
|
|
3698
3702
|
}
|
package/index.js
CHANGED
|
@@ -8541,9 +8541,21 @@ function processChildAgentFunction(childFunction, parentValues, parentInputKeys,
|
|
|
8541
8541
|
);
|
|
8542
8542
|
const originalFunc = processedFunction.func;
|
|
8543
8543
|
processedFunction.func = async (childArgs, funcOptions) => {
|
|
8544
|
+
let valuesToInject = {};
|
|
8545
|
+
if (Array.isArray(parentValues)) {
|
|
8546
|
+
const lastUserMessage = parentValues.filter((msg) => msg.role === "user").pop();
|
|
8547
|
+
if (lastUserMessage) {
|
|
8548
|
+
valuesToInject = pick(
|
|
8549
|
+
lastUserMessage.values,
|
|
8550
|
+
injectionKeys
|
|
8551
|
+
);
|
|
8552
|
+
}
|
|
8553
|
+
} else {
|
|
8554
|
+
valuesToInject = pick(parentValues, injectionKeys);
|
|
8555
|
+
}
|
|
8544
8556
|
const updatedChildArgs = {
|
|
8545
8557
|
...childArgs,
|
|
8546
|
-
...
|
|
8558
|
+
...valuesToInject
|
|
8547
8559
|
};
|
|
8548
8560
|
if (options.debug && injectionKeys.length > 0) {
|
|
8549
8561
|
const ai = funcOptions?.ai;
|
|
@@ -13532,7 +13544,17 @@ var AxRAG = class extends AxChainOfThought {
|
|
|
13532
13544
|
this.queryFn = queryFn;
|
|
13533
13545
|
this.register(this.genQuery);
|
|
13534
13546
|
}
|
|
13535
|
-
async forward(ai,
|
|
13547
|
+
async forward(ai, values, options) {
|
|
13548
|
+
let question;
|
|
13549
|
+
if (Array.isArray(values)) {
|
|
13550
|
+
const lastUserMessage = values.filter((msg) => msg.role === "user").pop();
|
|
13551
|
+
if (!lastUserMessage) {
|
|
13552
|
+
throw new Error("No user message found in values array");
|
|
13553
|
+
}
|
|
13554
|
+
question = lastUserMessage.values.question;
|
|
13555
|
+
} else {
|
|
13556
|
+
question = values.question;
|
|
13557
|
+
}
|
|
13536
13558
|
let hop = 0;
|
|
13537
13559
|
let context3 = [];
|
|
13538
13560
|
while (hop < this.maxHops) {
|