@ljoukov/llm 4.0.11 → 4.0.12
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/dist/index.cjs +12 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7436,8 +7436,6 @@ async function runToolLoop(request) {
|
|
|
7436
7436
|
let thoughtsText2 = "";
|
|
7437
7437
|
const modelParts = [];
|
|
7438
7438
|
const functionCalls = [];
|
|
7439
|
-
const seenFunctionCallIds = /* @__PURE__ */ new Set();
|
|
7440
|
-
const seenFunctionCallKeys = /* @__PURE__ */ new Set();
|
|
7441
7439
|
let latestUsageMetadata;
|
|
7442
7440
|
let resolvedModelVersion;
|
|
7443
7441
|
for await (const chunk of stream) {
|
|
@@ -7454,34 +7452,13 @@ async function runToolLoop(request) {
|
|
|
7454
7452
|
continue;
|
|
7455
7453
|
}
|
|
7456
7454
|
const primary = candidates[0];
|
|
7457
|
-
const parts = primary?.content?.parts;
|
|
7458
|
-
|
|
7455
|
+
const parts = primary?.content?.parts ?? [];
|
|
7456
|
+
const chunkFunctionCalls = chunk.functionCalls ?? [];
|
|
7457
|
+
if (parts.length === 0 && chunkFunctionCalls.length === 0) {
|
|
7459
7458
|
continue;
|
|
7460
7459
|
}
|
|
7461
7460
|
for (const part of parts) {
|
|
7462
7461
|
modelParts.push(part);
|
|
7463
|
-
const call = part.functionCall;
|
|
7464
|
-
if (call) {
|
|
7465
|
-
const id = typeof call.id === "string" ? call.id : "";
|
|
7466
|
-
const shouldAdd = (() => {
|
|
7467
|
-
if (id.length > 0) {
|
|
7468
|
-
if (seenFunctionCallIds.has(id)) {
|
|
7469
|
-
return false;
|
|
7470
|
-
}
|
|
7471
|
-
seenFunctionCallIds.add(id);
|
|
7472
|
-
return true;
|
|
7473
|
-
}
|
|
7474
|
-
const key = JSON.stringify({ name: call.name ?? "", args: call.args ?? null });
|
|
7475
|
-
if (seenFunctionCallKeys.has(key)) {
|
|
7476
|
-
return false;
|
|
7477
|
-
}
|
|
7478
|
-
seenFunctionCallKeys.add(key);
|
|
7479
|
-
return true;
|
|
7480
|
-
})();
|
|
7481
|
-
if (shouldAdd) {
|
|
7482
|
-
functionCalls.push(call);
|
|
7483
|
-
}
|
|
7484
|
-
}
|
|
7485
7462
|
if (typeof part.text === "string" && part.text.length > 0) {
|
|
7486
7463
|
if (part.thought) {
|
|
7487
7464
|
thoughtsText2 += part.text;
|
|
@@ -7494,6 +7471,15 @@ async function runToolLoop(request) {
|
|
|
7494
7471
|
}
|
|
7495
7472
|
}
|
|
7496
7473
|
}
|
|
7474
|
+
if (chunkFunctionCalls.length > 0) {
|
|
7475
|
+
functionCalls.push(...chunkFunctionCalls);
|
|
7476
|
+
continue;
|
|
7477
|
+
}
|
|
7478
|
+
for (const part of parts) {
|
|
7479
|
+
if (part.functionCall) {
|
|
7480
|
+
functionCalls.push(part.functionCall);
|
|
7481
|
+
}
|
|
7482
|
+
}
|
|
7497
7483
|
}
|
|
7498
7484
|
return {
|
|
7499
7485
|
responseText: responseText2,
|