@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.cjs
CHANGED
|
@@ -7710,6 +7710,22 @@ function parseFunctionCalls(ai, functionCalls, values, model) {
|
|
|
7710
7710
|
}));
|
|
7711
7711
|
return funcs;
|
|
7712
7712
|
}
|
|
7713
|
+
function createFunctionConfig(functionList, definedFunctionCall, firstStep) {
|
|
7714
|
+
let functionCall = definedFunctionCall;
|
|
7715
|
+
if (!firstStep && (functionCall === "required" || typeof functionCall === "function")) {
|
|
7716
|
+
return { functions: [], functionCall: void 0 };
|
|
7717
|
+
}
|
|
7718
|
+
if (!functionList) {
|
|
7719
|
+
return { functions: [], functionCall };
|
|
7720
|
+
}
|
|
7721
|
+
const functions = functionList.map((f2) => {
|
|
7722
|
+
if ("toFunction" in f2) {
|
|
7723
|
+
return f2.toFunction();
|
|
7724
|
+
}
|
|
7725
|
+
return f2;
|
|
7726
|
+
}).flat();
|
|
7727
|
+
return { functions, functionCall };
|
|
7728
|
+
}
|
|
7713
7729
|
|
|
7714
7730
|
// dsp/processResponse.ts
|
|
7715
7731
|
var import_web5 = require("stream/web");
|
|
@@ -10158,7 +10174,8 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
10158
10174
|
mem,
|
|
10159
10175
|
options,
|
|
10160
10176
|
traceContext,
|
|
10161
|
-
|
|
10177
|
+
functions,
|
|
10178
|
+
functionCall
|
|
10162
10179
|
}) {
|
|
10163
10180
|
const {
|
|
10164
10181
|
sessionId,
|
|
@@ -10166,8 +10183,6 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
10166
10183
|
model,
|
|
10167
10184
|
rateLimiter,
|
|
10168
10185
|
stream,
|
|
10169
|
-
functions: _functions,
|
|
10170
|
-
functionCall: _functionCall,
|
|
10171
10186
|
thinkingTokenBudget,
|
|
10172
10187
|
showThoughts
|
|
10173
10188
|
} = options ?? {};
|
|
@@ -10178,11 +10193,6 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
10178
10193
|
if (chatPrompt.length === 0) {
|
|
10179
10194
|
throw new Error("No chat prompt found");
|
|
10180
10195
|
}
|
|
10181
|
-
const functions = _functions?.map((f2) => "toFunction" in f2 ? f2.toFunction() : f2)?.flat();
|
|
10182
|
-
let functionCall = _functionCall ?? this.options?.functionCall;
|
|
10183
|
-
if (!firstStep && (functionCall === "required" || typeof functionCall === "function")) {
|
|
10184
|
-
functionCall = void 0;
|
|
10185
|
-
}
|
|
10186
10196
|
const modelConfig = {
|
|
10187
10197
|
...options?.modelConfig,
|
|
10188
10198
|
...options?.sampleCount ? { n: options.sampleCount } : {},
|
|
@@ -10219,18 +10229,24 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
10219
10229
|
span,
|
|
10220
10230
|
traceContext
|
|
10221
10231
|
}) {
|
|
10222
|
-
const { sessionId, traceId, functions:
|
|
10232
|
+
const { sessionId, traceId, functions: functionList } = options ?? {};
|
|
10233
|
+
const definedFunctionCall = options?.functionCall ?? this.options?.functionCall;
|
|
10223
10234
|
const strictMode = options?.strictMode ?? false;
|
|
10224
10235
|
const model = options.model;
|
|
10225
10236
|
const states = this.createStates(options.sampleCount ?? 1);
|
|
10226
10237
|
const usage = this.usage;
|
|
10227
|
-
const functions
|
|
10238
|
+
const { functions, functionCall } = createFunctionConfig(
|
|
10239
|
+
functionList,
|
|
10240
|
+
definedFunctionCall,
|
|
10241
|
+
firstStep
|
|
10242
|
+
);
|
|
10228
10243
|
const res = await this.forwardSendRequest({
|
|
10229
10244
|
ai,
|
|
10230
10245
|
mem,
|
|
10231
10246
|
options,
|
|
10232
10247
|
traceContext,
|
|
10233
|
-
|
|
10248
|
+
functions,
|
|
10249
|
+
functionCall
|
|
10234
10250
|
});
|
|
10235
10251
|
if (res instanceof import_web6.ReadableStream) {
|
|
10236
10252
|
yield* processStreamingResponse({
|