Fix Groq context window display (#7839)

This commit is contained in:
Matt Rubens 2025-09-10 00:50:57 -04:00 committed by GitHub
parent 48d592f433
commit 7cd6520302
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 13 deletions

View file

@ -149,7 +149,7 @@ describe("GroqHandler", () => {
expect(firstChunk.done).toBe(false)
expect(firstChunk.value).toMatchObject({
type: "usage",
inputTokens: 70, // 100 total - 30 cached
inputTokens: 100,
outputTokens: 50,
cacheWriteTokens: 0,
cacheReadTokens: 30,

View file

@ -66,20 +66,9 @@ export class GroqHandler extends BaseOpenAiCompatibleProvider<GroqModelId> {
// Calculate cost using OpenAI-compatible cost calculation
const totalCost = calculateApiCostOpenAI(info, inputTokens, outputTokens, cacheWriteTokens, cacheReadTokens)
// Calculate non-cached input tokens for proper reporting
const nonCachedInputTokens = Math.max(0, inputTokens - cacheReadTokens - cacheWriteTokens)
console.log("usage", {
inputTokens: nonCachedInputTokens,
outputTokens,
cacheWriteTokens,
cacheReadTokens,
totalCost,
})
yield {
type: "usage",
inputTokens: nonCachedInputTokens,
inputTokens,
outputTokens,
cacheWriteTokens,
cacheReadTokens,