@kenkaiiii/gg-ai 5.31.0 → 5.32.0
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 +6 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3376,14 +3376,16 @@ async function* runStream4(options) {
|
|
|
3376
3376
|
let thinkingAccum = "";
|
|
3377
3377
|
let stopReason = "end_turn";
|
|
3378
3378
|
let inputTokens = 0;
|
|
3379
|
-
let
|
|
3379
|
+
let candidateTokens = 0;
|
|
3380
|
+
let reasoningTokens = 0;
|
|
3380
3381
|
let cacheRead = 0;
|
|
3381
3382
|
let toolIndex = 0;
|
|
3382
3383
|
const handleResponse = function* (chunk) {
|
|
3383
3384
|
const usage = usageFromResponse(chunk);
|
|
3384
3385
|
if (usage) {
|
|
3385
3386
|
inputTokens = usage.promptTokenCount ?? inputTokens;
|
|
3386
|
-
|
|
3387
|
+
candidateTokens = usage.candidatesTokenCount ?? candidateTokens;
|
|
3388
|
+
reasoningTokens = usage.thoughtsTokenCount ?? reasoningTokens;
|
|
3387
3389
|
cacheRead = usage.cachedContentTokenCount ?? cacheRead;
|
|
3388
3390
|
}
|
|
3389
3391
|
const reason = finishReasonFromResponse(chunk);
|
|
@@ -3439,6 +3441,7 @@ async function* runStream4(options) {
|
|
|
3439
3441
|
}
|
|
3440
3442
|
if (pendingToolCalls.length > 0) stopReason = "tool_use";
|
|
3441
3443
|
const adjustedInputTokens = Math.max(0, inputTokens - cacheRead);
|
|
3444
|
+
const outputTokens = candidateTokens + reasoningTokens;
|
|
3442
3445
|
const streamResponse = {
|
|
3443
3446
|
message: {
|
|
3444
3447
|
role: "assistant",
|
|
@@ -3448,6 +3451,7 @@ async function* runStream4(options) {
|
|
|
3448
3451
|
usage: {
|
|
3449
3452
|
inputTokens: adjustedInputTokens,
|
|
3450
3453
|
outputTokens,
|
|
3454
|
+
...reasoningTokens > 0 ? { reasoningTokens } : {},
|
|
3451
3455
|
...cacheRead > 0 ? { cacheRead } : {}
|
|
3452
3456
|
}
|
|
3453
3457
|
};
|