ai 3.2.25 → 3.2.27
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.js +17 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -627,7 +627,8 @@ async function generateObject({
|
|
627
627
|
...prepareCallSettings(settings),
|
628
628
|
inputFormat: validatedPrompt.type,
|
629
629
|
prompt: convertToLanguageModelPrompt(validatedPrompt),
|
630
|
-
abortSignal
|
630
|
+
abortSignal,
|
631
|
+
headers
|
631
632
|
})
|
632
633
|
);
|
633
634
|
if (generateResult.text === void 0) {
|
@@ -661,7 +662,8 @@ async function generateObject({
|
|
661
662
|
...prepareCallSettings(settings),
|
662
663
|
inputFormat: validatedPrompt.type,
|
663
664
|
prompt: convertToLanguageModelPrompt(validatedPrompt),
|
664
|
-
abortSignal
|
665
|
+
abortSignal,
|
666
|
+
headers
|
665
667
|
})
|
666
668
|
);
|
667
669
|
const functionArgs = (_b = (_a = generateResult.toolCalls) == null ? void 0 : _a[0]) == null ? void 0 : _b.args;
|
@@ -1365,6 +1367,11 @@ async function generateText({
|
|
1365
1367
|
let roundtripCount = 0;
|
1366
1368
|
const responseMessages = [];
|
1367
1369
|
const roundtrips = [];
|
1370
|
+
const usage = {
|
1371
|
+
completionTokens: 0,
|
1372
|
+
promptTokens: 0,
|
1373
|
+
totalTokens: 0
|
1374
|
+
};
|
1368
1375
|
do {
|
1369
1376
|
const currentInputFormat = roundtripCount === 0 ? validatedPrompt.type : "messages";
|
1370
1377
|
currentModelResponse = await retry(
|
@@ -1404,12 +1411,18 @@ async function generateText({
|
|
1404
1411
|
tools,
|
1405
1412
|
tracer
|
1406
1413
|
});
|
1414
|
+
const currentUsage = calculateCompletionTokenUsage(
|
1415
|
+
currentModelResponse.usage
|
1416
|
+
);
|
1417
|
+
usage.completionTokens += currentUsage.completionTokens;
|
1418
|
+
usage.promptTokens += currentUsage.promptTokens;
|
1419
|
+
usage.totalTokens += currentUsage.totalTokens;
|
1407
1420
|
roundtrips.push({
|
1408
1421
|
text: (_b = currentModelResponse.text) != null ? _b : "",
|
1409
1422
|
toolCalls: currentToolCalls,
|
1410
1423
|
toolResults: currentToolResults,
|
1411
1424
|
finishReason: currentModelResponse.finishReason,
|
1412
|
-
usage:
|
1425
|
+
usage: currentUsage,
|
1413
1426
|
warnings: currentModelResponse.warnings,
|
1414
1427
|
logprobs: currentModelResponse.logprobs
|
1415
1428
|
});
|
@@ -1443,7 +1456,7 @@ async function generateText({
|
|
1443
1456
|
toolCalls: currentToolCalls,
|
1444
1457
|
toolResults: currentToolResults,
|
1445
1458
|
finishReason: currentModelResponse.finishReason,
|
1446
|
-
usage
|
1459
|
+
usage,
|
1447
1460
|
warnings: currentModelResponse.warnings,
|
1448
1461
|
rawResponse: currentModelResponse.rawResponse,
|
1449
1462
|
logprobs: currentModelResponse.logprobs,
|