Skip to content

Commit ee67174

Browse files
hannesrudolphdaniel-lxs
authored andcommitted
fix: address PR review feedback for service tier implementation
- Fixed documentation comment about streaming behavior (service_tier IS sent for streaming) - Added internationalization for all UI strings (Service tier, Standard, Flex, Priority, pricing table) - Fixed TypeScript type safety by using proper ServiceTier type instead of 'any' casts - All tests passing, TypeScript compilation successful
1 parent 5a39c3a commit ee67174

File tree

2 files changed

+58
-21
lines changed

2 files changed

+58
-21
lines changed

webview-ui/src/components/settings/ModelInfoView.tsx

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ export const ModelInfoView = ({
2626
const { t } = useAppTranslation()
2727

2828
// Show tiered pricing table for OpenAI Native when model supports non-standard tiers
29-
const allowedTiers =
30-
(modelInfo?.allowedServiceTiers || []).filter((tier) => tier === "flex" || tier === "priority") ?? []
31-
const tierPricing = modelInfo?.serviceTierPricing
32-
const shouldShowTierPricingTable = apiProvider === "openai-native" && allowedTiers.length > 0 && !!tierPricing
29+
const allowedTierNames =
30+
modelInfo?.tiers?.filter((t) => t.name === "flex" || t.name === "priority")?.map((t) => t.name) ?? []
31+
const shouldShowTierPricingTable = apiProvider === "openai-native" && allowedTierNames.length > 0
3332
const fmt = (n?: number) => (typeof n === "number" ? `${formatPrice(n)}` : "—")
3433

3534
const baseInfoItems = [
@@ -122,50 +121,74 @@ export const ModelInfoView = ({
122121
{shouldShowTierPricingTable && (
123122
<div className="mt-2">
124123
<div className="text-xs text-vscode-descriptionForeground mb-1">
125-
Pricing by service tier (price per 1M tokens)
124+
{t("settings:serviceTier.pricingTableTitle")}
126125
</div>
127126
<div className="border border-vscode-dropdown-border rounded-xs overflow-hidden">
128127
<table className="w-full text-sm">
129128
<thead className="bg-vscode-dropdown-background">
130129
<tr>
131-
<th className="text-left px-3 py-1.5">Tier</th>
132-
<th className="text-right px-3 py-1.5">Input</th>
133-
<th className="text-right px-3 py-1.5">Output</th>
134-
<th className="text-right px-3 py-1.5">Cache reads</th>
130+
<th className="text-left px-3 py-1.5">{t("settings:serviceTier.columns.tier")}</th>
131+
<th className="text-right px-3 py-1.5">
132+
{t("settings:serviceTier.columns.input")}
133+
</th>
134+
<th className="text-right px-3 py-1.5">
135+
{t("settings:serviceTier.columns.output")}
136+
</th>
137+
<th className="text-right px-3 py-1.5">
138+
{t("settings:serviceTier.columns.cacheReads")}
139+
</th>
135140
</tr>
136141
</thead>
137142
<tbody>
138143
<tr className="border-t border-vscode-dropdown-border/60">
139-
<td className="px-3 py-1.5">Standard</td>
144+
<td className="px-3 py-1.5">{t("settings:serviceTier.standard")}</td>
140145
<td className="px-3 py-1.5 text-right">{fmt(modelInfo?.inputPrice)}</td>
141146
<td className="px-3 py-1.5 text-right">{fmt(modelInfo?.outputPrice)}</td>
142147
<td className="px-3 py-1.5 text-right">{fmt(modelInfo?.cacheReadsPrice)}</td>
143148
</tr>
144-
{allowedTiers.includes("flex") && (
149+
{allowedTierNames.includes("flex") && (
145150
<tr className="border-t border-vscode-dropdown-border/60">
146-
<td className="px-3 py-1.5">Flex</td>
151+
<td className="px-3 py-1.5">{t("settings:serviceTier.flex")}</td>
147152
<td className="px-3 py-1.5 text-right">
148-
{fmt(tierPricing?.flex?.inputPrice ?? modelInfo?.inputPrice)}
153+
{fmt(
154+
modelInfo?.tiers?.find((t) => t.name === "flex")?.inputPrice ??
155+
modelInfo?.inputPrice,
156+
)}
149157
</td>
150158
<td className="px-3 py-1.5 text-right">
151-
{fmt(tierPricing?.flex?.outputPrice ?? modelInfo?.outputPrice)}
159+
{fmt(
160+
modelInfo?.tiers?.find((t) => t.name === "flex")?.outputPrice ??
161+
modelInfo?.outputPrice,
162+
)}
152163
</td>
153164
<td className="px-3 py-1.5 text-right">
154-
{fmt(tierPricing?.flex?.cacheReadsPrice ?? modelInfo?.cacheReadsPrice)}
165+
{fmt(
166+
modelInfo?.tiers?.find((t) => t.name === "flex")?.cacheReadsPrice ??
167+
modelInfo?.cacheReadsPrice,
168+
)}
155169
</td>
156170
</tr>
157171
)}
158-
{allowedTiers.includes("priority") && (
172+
{allowedTierNames.includes("priority") && (
159173
<tr className="border-t border-vscode-dropdown-border/60">
160-
<td className="px-3 py-1.5">Priority</td>
174+
<td className="px-3 py-1.5">{t("settings:serviceTier.priority")}</td>
161175
<td className="px-3 py-1.5 text-right">
162-
{fmt(tierPricing?.priority?.inputPrice ?? modelInfo?.inputPrice)}
176+
{fmt(
177+
modelInfo?.tiers?.find((t) => t.name === "priority")?.inputPrice ??
178+
modelInfo?.inputPrice,
179+
)}
163180
</td>
164181
<td className="px-3 py-1.5 text-right">
165-
{fmt(tierPricing?.priority?.outputPrice ?? modelInfo?.outputPrice)}
182+
{fmt(
183+
modelInfo?.tiers?.find((t) => t.name === "priority")?.outputPrice ??
184+
modelInfo?.outputPrice,
185+
)}
166186
</td>
167187
<td className="px-3 py-1.5 text-right">
168-
{fmt(tierPricing?.priority?.cacheReadsPrice ?? modelInfo?.cacheReadsPrice)}
188+
{fmt(
189+
modelInfo?.tiers?.find((t) => t.name === "priority")?.cacheReadsPrice ??
190+
modelInfo?.cacheReadsPrice,
191+
)}
169192
</td>
170193
</tr>
171194
)}

webview-ui/src/i18n/locales/en/settings.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,5 +857,19 @@
857857
"includeMaxOutputTokensDescription": "Send max output tokens parameter in API requests. Some providers may not support this.",
858858
"limitMaxTokensDescription": "Limit the maximum number of tokens in the response",
859859
"maxOutputTokensLabel": "Max output tokens",
860-
"maxTokensGenerateDescription": "Maximum tokens to generate in response"
860+
"maxTokensGenerateDescription": "Maximum tokens to generate in response",
861+
"serviceTier": {
862+
"label": "Service tier",
863+
"tooltip": "For faster processing of API requests, try the priority processing service tier. For lower prices with higher latency, try the flex processing tier.",
864+
"standard": "Standard",
865+
"flex": "Flex",
866+
"priority": "Priority",
867+
"pricingTableTitle": "Pricing by service tier (price per 1M tokens)",
868+
"columns": {
869+
"tier": "Tier",
870+
"input": "Input",
871+
"output": "Output",
872+
"cacheReads": "Cache reads"
873+
}
874+
}
861875
}

0 commit comments

Comments
 (0)