Skip to content

Commit dbd835d

Browse files
committed
fix(webview-ui): narrow gemini tier typing and pricing fields; re-trigger CI
1 parent c6d8aaf commit dbd835d

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

webview-ui/src/components/ui/hooks/useSelectedModel.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -308,21 +308,34 @@ function getSelectedModel({
308308
}
309309
case "gemini": {
310310
const id = apiConfiguration.apiModelId ?? geminiDefaultModelId
311-
const baseInfo = geminiModels[id as keyof typeof geminiModels]
312-
if (baseInfo && apiConfiguration.largeInputTierEnabled && baseInfo.tiers && baseInfo.tiers.length > 0) {
311+
const base = geminiModels[id as keyof typeof geminiModels]
312+
if (!base) {
313+
return { id, info: undefined }
314+
}
315+
316+
// Coerce to ModelInfo for consistent optional fields (tiers, cache*Price, etc.)
317+
const mi = base as ModelInfo
318+
const tiers = mi.tiers
319+
320+
if (apiConfiguration.largeInputTierEnabled && Array.isArray(tiers) && tiers.length > 0) {
313321
// Select the highest contextWindow tier and apply its pricing overrides
314-
const highTier = baseInfo.tiers.reduce((acc, t) => (t.contextWindow > acc.contextWindow ? t : acc))
322+
type Tier = NonNullable<ModelInfo["tiers"]>[number]
323+
const highTier = (tiers as Tier[]).reduce(
324+
(acc: Tier, t: Tier) => (t.contextWindow > acc.contextWindow ? t : acc),
325+
tiers[0] as Tier,
326+
)
315327
const info: ModelInfo = {
316-
...baseInfo,
328+
...mi,
317329
contextWindow: highTier.contextWindow,
318-
inputPrice: highTier.inputPrice ?? baseInfo.inputPrice,
319-
outputPrice: highTier.outputPrice ?? baseInfo.outputPrice,
320-
cacheWritesPrice: highTier.cacheWritesPrice ?? baseInfo.cacheWritesPrice,
321-
cacheReadsPrice: highTier.cacheReadsPrice ?? baseInfo.cacheReadsPrice,
330+
inputPrice: highTier.inputPrice ?? mi.inputPrice,
331+
outputPrice: highTier.outputPrice ?? mi.outputPrice,
332+
cacheWritesPrice: highTier.cacheWritesPrice ?? mi.cacheWritesPrice,
333+
cacheReadsPrice: highTier.cacheReadsPrice ?? mi.cacheReadsPrice,
322334
}
323335
return { id, info }
324336
}
325-
return { id, info: baseInfo }
337+
338+
return { id, info: mi }
326339
}
327340
case "deepseek": {
328341
const id = apiConfiguration.apiModelId ?? deepSeekDefaultModelId

0 commit comments

Comments
 (0)