@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.d.cts
CHANGED
|
@@ -173,7 +173,10 @@ interface StreamResponse {
|
|
|
173
173
|
}
|
|
174
174
|
interface Usage {
|
|
175
175
|
inputTokens: number;
|
|
176
|
+
/** Total billed output tokens, including reasoning tokens when the provider reports them separately. */
|
|
176
177
|
outputTokens: number;
|
|
178
|
+
/** Reasoning/thinking-token subset of outputTokens. */
|
|
179
|
+
reasoningTokens?: number;
|
|
177
180
|
cacheRead?: number;
|
|
178
181
|
cacheWrite?: number;
|
|
179
182
|
serverToolUse?: {
|
package/dist/index.d.ts
CHANGED
|
@@ -173,7 +173,10 @@ interface StreamResponse {
|
|
|
173
173
|
}
|
|
174
174
|
interface Usage {
|
|
175
175
|
inputTokens: number;
|
|
176
|
+
/** Total billed output tokens, including reasoning tokens when the provider reports them separately. */
|
|
176
177
|
outputTokens: number;
|
|
178
|
+
/** Reasoning/thinking-token subset of outputTokens. */
|
|
179
|
+
reasoningTokens?: number;
|
|
177
180
|
cacheRead?: number;
|
|
178
181
|
cacheWrite?: number;
|
|
179
182
|
serverToolUse?: {
|
package/dist/index.js
CHANGED
|
@@ -3315,14 +3315,16 @@ async function* runStream4(options) {
|
|
|
3315
3315
|
let thinkingAccum = "";
|
|
3316
3316
|
let stopReason = "end_turn";
|
|
3317
3317
|
let inputTokens = 0;
|
|
3318
|
-
let
|
|
3318
|
+
let candidateTokens = 0;
|
|
3319
|
+
let reasoningTokens = 0;
|
|
3319
3320
|
let cacheRead = 0;
|
|
3320
3321
|
let toolIndex = 0;
|
|
3321
3322
|
const handleResponse = function* (chunk) {
|
|
3322
3323
|
const usage = usageFromResponse(chunk);
|
|
3323
3324
|
if (usage) {
|
|
3324
3325
|
inputTokens = usage.promptTokenCount ?? inputTokens;
|
|
3325
|
-
|
|
3326
|
+
candidateTokens = usage.candidatesTokenCount ?? candidateTokens;
|
|
3327
|
+
reasoningTokens = usage.thoughtsTokenCount ?? reasoningTokens;
|
|
3326
3328
|
cacheRead = usage.cachedContentTokenCount ?? cacheRead;
|
|
3327
3329
|
}
|
|
3328
3330
|
const reason = finishReasonFromResponse(chunk);
|
|
@@ -3378,6 +3380,7 @@ async function* runStream4(options) {
|
|
|
3378
3380
|
}
|
|
3379
3381
|
if (pendingToolCalls.length > 0) stopReason = "tool_use";
|
|
3380
3382
|
const adjustedInputTokens = Math.max(0, inputTokens - cacheRead);
|
|
3383
|
+
const outputTokens = candidateTokens + reasoningTokens;
|
|
3381
3384
|
const streamResponse = {
|
|
3382
3385
|
message: {
|
|
3383
3386
|
role: "assistant",
|
|
@@ -3387,6 +3390,7 @@ async function* runStream4(options) {
|
|
|
3387
3390
|
usage: {
|
|
3388
3391
|
inputTokens: adjustedInputTokens,
|
|
3389
3392
|
outputTokens,
|
|
3393
|
+
...reasoningTokens > 0 ? { reasoningTokens } : {},
|
|
3390
3394
|
...cacheRead > 0 ? { cacheRead } : {}
|
|
3391
3395
|
}
|
|
3392
3396
|
};
|