@ax-llm/ax 12.0.14 → 12.0.16
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 +35 -15
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -0
- package/index.d.ts +2 -0
- package/index.js +35 -15
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.cts
CHANGED
|
@@ -2134,6 +2134,7 @@ declare class AxAIGrok extends AxAIOpenAIBase<AxAIGrokModel, AxAIGrokEmbedModels
|
|
|
2134
2134
|
type AxMemoryData = {
|
|
2135
2135
|
tags?: string[];
|
|
2136
2136
|
role: AxChatRequest['chatPrompt'][number]['role'];
|
|
2137
|
+
updatable?: boolean;
|
|
2137
2138
|
chat: {
|
|
2138
2139
|
index: number;
|
|
2139
2140
|
value: Omit<AxChatRequest['chatPrompt'][number], 'role'>;
|
|
@@ -2319,6 +2320,7 @@ declare class AxMemory implements AxAIMemory {
|
|
|
2319
2320
|
getLast(sessionId?: string): {
|
|
2320
2321
|
tags?: string[];
|
|
2321
2322
|
role: AxChatRequest["chatPrompt"][number]["role"];
|
|
2323
|
+
updatable?: boolean;
|
|
2322
2324
|
chat: {
|
|
2323
2325
|
index: number;
|
|
2324
2326
|
value: Omit<AxChatRequest["chatPrompt"][number], "role">;
|
package/index.d.ts
CHANGED
|
@@ -2134,6 +2134,7 @@ declare class AxAIGrok extends AxAIOpenAIBase<AxAIGrokModel, AxAIGrokEmbedModels
|
|
|
2134
2134
|
type AxMemoryData = {
|
|
2135
2135
|
tags?: string[];
|
|
2136
2136
|
role: AxChatRequest['chatPrompt'][number]['role'];
|
|
2137
|
+
updatable?: boolean;
|
|
2137
2138
|
chat: {
|
|
2138
2139
|
index: number;
|
|
2139
2140
|
value: Omit<AxChatRequest['chatPrompt'][number], 'role'>;
|
|
@@ -2319,6 +2320,7 @@ declare class AxMemory implements AxAIMemory {
|
|
|
2319
2320
|
getLast(sessionId?: string): {
|
|
2320
2321
|
tags?: string[];
|
|
2321
2322
|
role: AxChatRequest["chatPrompt"][number]["role"];
|
|
2323
|
+
updatable?: boolean;
|
|
2322
2324
|
chat: {
|
|
2323
2325
|
index: number;
|
|
2324
2326
|
value: Omit<AxChatRequest["chatPrompt"][number], "role">;
|
package/index.js
CHANGED
|
@@ -6124,9 +6124,10 @@ var MemoryImpl = class {
|
|
|
6124
6124
|
}
|
|
6125
6125
|
}
|
|
6126
6126
|
};
|
|
6127
|
-
if (!lastItem || lastItem.role !== "assistant") {
|
|
6127
|
+
if (!lastItem || lastItem.role !== "assistant" || lastItem.role === "assistant" && !lastItem.updatable) {
|
|
6128
6128
|
this.data.push({
|
|
6129
6129
|
role: "assistant",
|
|
6130
|
+
updatable: true,
|
|
6130
6131
|
chat: [
|
|
6131
6132
|
{ index, value: structuredClone({ content, name, functionCalls }) }
|
|
6132
6133
|
]
|
|
@@ -6143,13 +6144,16 @@ var MemoryImpl = class {
|
|
|
6143
6144
|
log();
|
|
6144
6145
|
return;
|
|
6145
6146
|
}
|
|
6146
|
-
if (
|
|
6147
|
+
if (typeof content === "string" && content.trim() !== "") {
|
|
6148
|
+
;
|
|
6147
6149
|
chat.value.content = content;
|
|
6148
6150
|
}
|
|
6149
|
-
if (
|
|
6151
|
+
if (typeof name === "string" && name.trim() !== "") {
|
|
6152
|
+
;
|
|
6150
6153
|
chat.value.name = name;
|
|
6151
6154
|
}
|
|
6152
|
-
if (
|
|
6155
|
+
if (Array.isArray(functionCalls) && functionCalls.length > 0) {
|
|
6156
|
+
;
|
|
6153
6157
|
chat.value.functionCalls = functionCalls;
|
|
6154
6158
|
}
|
|
6155
6159
|
log();
|
|
@@ -7536,6 +7540,22 @@ function parseFunctionCalls(ai, functionCalls, values, model) {
|
|
|
7536
7540
|
}));
|
|
7537
7541
|
return funcs;
|
|
7538
7542
|
}
|
|
7543
|
+
function createFunctionConfig(functionList, definedFunctionCall, firstStep) {
|
|
7544
|
+
let functionCall = definedFunctionCall;
|
|
7545
|
+
if (!firstStep && (functionCall === "required" || typeof functionCall === "function")) {
|
|
7546
|
+
return { functions: [], functionCall: void 0 };
|
|
7547
|
+
}
|
|
7548
|
+
if (!functionList) {
|
|
7549
|
+
return { functions: [], functionCall };
|
|
7550
|
+
}
|
|
7551
|
+
const functions = functionList.map((f2) => {
|
|
7552
|
+
if ("toFunction" in f2) {
|
|
7553
|
+
return f2.toFunction();
|
|
7554
|
+
}
|
|
7555
|
+
return f2;
|
|
7556
|
+
}).flat();
|
|
7557
|
+
return { functions, functionCall };
|
|
7558
|
+
}
|
|
7539
7559
|
|
|
7540
7560
|
// dsp/processResponse.ts
|
|
7541
7561
|
import "stream/web";
|
|
@@ -9984,7 +10004,8 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
9984
10004
|
mem,
|
|
9985
10005
|
options,
|
|
9986
10006
|
traceContext,
|
|
9987
|
-
|
|
10007
|
+
functions,
|
|
10008
|
+
functionCall
|
|
9988
10009
|
}) {
|
|
9989
10010
|
const {
|
|
9990
10011
|
sessionId,
|
|
@@ -9992,8 +10013,6 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
9992
10013
|
model,
|
|
9993
10014
|
rateLimiter,
|
|
9994
10015
|
stream,
|
|
9995
|
-
functions: _functions,
|
|
9996
|
-
functionCall: _functionCall,
|
|
9997
10016
|
thinkingTokenBudget,
|
|
9998
10017
|
showThoughts
|
|
9999
10018
|
} = options ?? {};
|
|
@@ -10004,11 +10023,6 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
10004
10023
|
if (chatPrompt.length === 0) {
|
|
10005
10024
|
throw new Error("No chat prompt found");
|
|
10006
10025
|
}
|
|
10007
|
-
const functions = _functions?.map((f2) => "toFunction" in f2 ? f2.toFunction() : f2)?.flat();
|
|
10008
|
-
let functionCall = _functionCall ?? this.options?.functionCall;
|
|
10009
|
-
if (!firstStep && (functionCall === "required" || typeof functionCall === "function")) {
|
|
10010
|
-
functionCall = void 0;
|
|
10011
|
-
}
|
|
10012
10026
|
const modelConfig = {
|
|
10013
10027
|
...options?.modelConfig,
|
|
10014
10028
|
...options?.sampleCount ? { n: options.sampleCount } : {},
|
|
@@ -10045,18 +10059,24 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
10045
10059
|
span,
|
|
10046
10060
|
traceContext
|
|
10047
10061
|
}) {
|
|
10048
|
-
const { sessionId, traceId, functions:
|
|
10062
|
+
const { sessionId, traceId, functions: functionList } = options ?? {};
|
|
10063
|
+
const definedFunctionCall = options?.functionCall ?? this.options?.functionCall;
|
|
10049
10064
|
const strictMode = options?.strictMode ?? false;
|
|
10050
10065
|
const model = options.model;
|
|
10051
10066
|
const states = this.createStates(options.sampleCount ?? 1);
|
|
10052
10067
|
const usage = this.usage;
|
|
10053
|
-
const functions
|
|
10068
|
+
const { functions, functionCall } = createFunctionConfig(
|
|
10069
|
+
functionList,
|
|
10070
|
+
definedFunctionCall,
|
|
10071
|
+
firstStep
|
|
10072
|
+
);
|
|
10054
10073
|
const res = await this.forwardSendRequest({
|
|
10055
10074
|
ai,
|
|
10056
10075
|
mem,
|
|
10057
10076
|
options,
|
|
10058
10077
|
traceContext,
|
|
10059
|
-
|
|
10078
|
+
functions,
|
|
10079
|
+
functionCall
|
|
10060
10080
|
});
|
|
10061
10081
|
if (res instanceof ReadableStream3) {
|
|
10062
10082
|
yield* processStreamingResponse({
|