Skip to content

Commit e684ace

Browse files
committed
gemini token logging in output channel
1 parent 8be06ed commit e684ace

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/api/providers/gemini.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type { JWTInput } from "google-auth-library"
1010

1111
import { type ModelInfo, type GeminiModelId, geminiDefaultModelId, geminiModels } from "@roo-code/types"
1212

13+
import { getGeminiTokenChannel } from "../../core/output-channel"
1314
import type { ApiHandlerOptions } from "../../shared/api"
1415
import { safeJsonParse } from "../../shared/safeJsonParse"
1516

@@ -144,6 +145,13 @@ export class GeminiHandler extends BaseProvider implements SingleCompletionHandl
144145
const cacheReadTokens = lastUsageMetadata.cachedContentTokenCount
145146
const reasoningTokens = lastUsageMetadata.thoughtsTokenCount
146147

148+
const channel = getGeminiTokenChannel()
149+
channel.appendLine(
150+
`Gemini Usage - Model: ${model}, Prompt: ${inputTokens}, Candidates: ${outputTokens}, Cached: ${
151+
cacheReadTokens ?? 0
152+
}, Thoughts: ${reasoningTokens ?? 0}, Total: ${lastUsageMetadata.totalTokenCount}`,
153+
)
154+
147155
yield {
148156
type: "usage",
149157
inputTokens,

src/core/output-channel.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as vscode from "vscode"
2+
3+
let geminiTokenChannel: vscode.OutputChannel | undefined
4+
5+
export function getGeminiTokenChannel(): vscode.OutputChannel {
6+
if (!geminiTokenChannel) {
7+
geminiTokenChannel = vscode.window.createOutputChannel("Roo-Code Gemini Tokens")
8+
}
9+
return geminiTokenChannel
10+
}

0 commit comments

Comments
 (0)