@ax-llm/ax 12.0.14 → 12.0.15
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 +27 -11
- package/index.cjs.map +1 -1
- package/index.js +27 -11
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -7536,6 +7536,22 @@ function parseFunctionCalls(ai, functionCalls, values, model) {
|
|
|
7536
7536
|
}));
|
|
7537
7537
|
return funcs;
|
|
7538
7538
|
}
|
|
7539
|
+
function createFunctionConfig(functionList, definedFunctionCall, firstStep) {
|
|
7540
|
+
let functionCall = definedFunctionCall;
|
|
7541
|
+
if (!firstStep && (functionCall === "required" || typeof functionCall === "function")) {
|
|
7542
|
+
return { functions: [], functionCall: void 0 };
|
|
7543
|
+
}
|
|
7544
|
+
if (!functionList) {
|
|
7545
|
+
return { functions: [], functionCall };
|
|
7546
|
+
}
|
|
7547
|
+
const functions = functionList.map((f2) => {
|
|
7548
|
+
if ("toFunction" in f2) {
|
|
7549
|
+
return f2.toFunction();
|
|
7550
|
+
}
|
|
7551
|
+
return f2;
|
|
7552
|
+
}).flat();
|
|
7553
|
+
return { functions, functionCall };
|
|
7554
|
+
}
|
|
7539
7555
|
|
|
7540
7556
|
// dsp/processResponse.ts
|
|
7541
7557
|
import "stream/web";
|
|
@@ -9984,7 +10000,8 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
9984
10000
|
mem,
|
|
9985
10001
|
options,
|
|
9986
10002
|
traceContext,
|
|
9987
|
-
|
|
10003
|
+
functions,
|
|
10004
|
+
functionCall
|
|
9988
10005
|
}) {
|
|
9989
10006
|
const {
|
|
9990
10007
|
sessionId,
|
|
@@ -9992,8 +10009,6 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
9992
10009
|
model,
|
|
9993
10010
|
rateLimiter,
|
|
9994
10011
|
stream,
|
|
9995
|
-
functions: _functions,
|
|
9996
|
-
functionCall: _functionCall,
|
|
9997
10012
|
thinkingTokenBudget,
|
|
9998
10013
|
showThoughts
|
|
9999
10014
|
} = options ?? {};
|
|
@@ -10004,11 +10019,6 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
10004
10019
|
if (chatPrompt.length === 0) {
|
|
10005
10020
|
throw new Error("No chat prompt found");
|
|
10006
10021
|
}
|
|
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
10022
|
const modelConfig = {
|
|
10013
10023
|
...options?.modelConfig,
|
|
10014
10024
|
...options?.sampleCount ? { n: options.sampleCount } : {},
|
|
@@ -10045,18 +10055,24 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
10045
10055
|
span,
|
|
10046
10056
|
traceContext
|
|
10047
10057
|
}) {
|
|
10048
|
-
const { sessionId, traceId, functions:
|
|
10058
|
+
const { sessionId, traceId, functions: functionList } = options ?? {};
|
|
10059
|
+
const definedFunctionCall = options?.functionCall ?? this.options?.functionCall;
|
|
10049
10060
|
const strictMode = options?.strictMode ?? false;
|
|
10050
10061
|
const model = options.model;
|
|
10051
10062
|
const states = this.createStates(options.sampleCount ?? 1);
|
|
10052
10063
|
const usage = this.usage;
|
|
10053
|
-
const functions
|
|
10064
|
+
const { functions, functionCall } = createFunctionConfig(
|
|
10065
|
+
functionList,
|
|
10066
|
+
definedFunctionCall,
|
|
10067
|
+
firstStep
|
|
10068
|
+
);
|
|
10054
10069
|
const res = await this.forwardSendRequest({
|
|
10055
10070
|
ai,
|
|
10056
10071
|
mem,
|
|
10057
10072
|
options,
|
|
10058
10073
|
traceContext,
|
|
10059
|
-
|
|
10074
|
+
functions,
|
|
10075
|
+
functionCall
|
|
10060
10076
|
});
|
|
10061
10077
|
if (res instanceof ReadableStream3) {
|
|
10062
10078
|
yield* processStreamingResponse({
|