mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: apply tiered pricing for Gemini models via Vertex AI (#8018)
* fix: apply tiered pricing for Gemini models via Vertex AI - Modified calculateCost method to handle models where cacheReadsPrice is only defined in tiers - Added comprehensive tests for Vertex AI tiered pricing calculation - Fixes issue where local cost calculation always showed highest tier rates Fixes #8017 * Delete src/api/providers/__tests__/vertex-tiered-pricing.spec.ts --------- Co-authored-by: Roo Code <roomote@roocode.com> Co-authored-by: Daniel <57051444+daniel-lxs@users.noreply.github.com>
This commit is contained in:
parent
c1e0cdc3cd
commit
c0e2c5ef5b
1 changed files with 11 additions and 4 deletions
|
|
@ -286,10 +286,7 @@ export class GeminiHandler extends BaseProvider implements SingleCompletionHandl
|
|||
outputTokens: number
|
||||
cacheReadTokens?: number
|
||||
}) {
|
||||
if (!info.inputPrice || !info.outputPrice || !info.cacheReadsPrice) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
// For models with tiered pricing, prices might only be defined in tiers
|
||||
let inputPrice = info.inputPrice
|
||||
let outputPrice = info.outputPrice
|
||||
let cacheReadsPrice = info.cacheReadsPrice
|
||||
|
|
@ -306,6 +303,16 @@ export class GeminiHandler extends BaseProvider implements SingleCompletionHandl
|
|||
}
|
||||
}
|
||||
|
||||
// Check if we have the required prices after considering tiers
|
||||
if (!inputPrice || !outputPrice) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
// cacheReadsPrice is optional - if not defined, treat as 0
|
||||
if (!cacheReadsPrice) {
|
||||
cacheReadsPrice = 0
|
||||
}
|
||||
|
||||
// Subtract the cached input tokens from the total input tokens.
|
||||
const uncachedInputTokens = inputTokens - cacheReadTokens
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue