Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

feat(models): label primary pricing by charge component

fmfsaisaibffac7e0debc
diff --git a/apps/desktop/scripts/fixtures/display-pricing/display-pricing-fixture.tsx b/apps/desktop/scripts/fixtures/display-pricing/display-pricing-fixture.tsx
index 3a2883a788..ab0c56d7b8 100644
--- a/apps/desktop/scripts/fixtures/display-pricing/display-pricing-fixture.tsx
+++ b/apps/desktop/scripts/fixtures/display-pricing/display-pricing-fixture.tsx
@@ -9,7 +9,7 @@ import {
const speech: ModelDisplayPricing = {
items: [{ label: 'Text input', price: 140, unit: 'character', quantity: 1000000 }],
- summary: { input: [{ price: 140, unit: 'character', quantity: 1000000 }] },
+ summary: { input: [{ price: 140, unit: 'character', quantity: 1000000, component: 'text' }] },
};
const image: ModelDisplayPricing = {
items: [
@@ -17,8 +17,8 @@ const image: ModelDisplayPricing = {
{ label: 'Output image', price: 0.3, unit: 'image', quantity: 1 },
],
summary: {
- input: [{ price: 0.02, unit: 'image', quantity: 1 }],
- output: [{ price: 0.3, unit: 'image', quantity: 1 }],
+ input: [{ price: 0.02, unit: 'image', quantity: 1, component: 'image' }],
+ output: [{ price: 0.3, unit: 'image', quantity: 1, component: 'image' }],
},
};
const video: ModelDisplayPricing = {
@@ -34,6 +34,7 @@ const video: ModelDisplayPricing = {
price: 0.05,
maxPrice: 0.2,
tier: '480P/720P/1080P',
+ component: 'video',
unit: 'second',
quantity: 1,
},
@@ -64,6 +65,40 @@ const compact: ModelDisplayPricing = {
},
};
+const components: ModelDisplayPricing = {
+ items: [
+ { label: 'Text Input', price: 2, unit: 'token', quantity: 1000000 },
+ { label: 'Image Output', price: 840, unit: 'token', quantity: 1000000 },
+ { label: 'Image Output', price: 0.134, unit: 'image', quantity: 1 },
+ ],
+ summary: {
+ input: [{ component: 'text', price: 2, unit: 'token', quantity: 1000000 }],
+ output: [{ component: 'image', price: 840, unit: 'token', quantity: 1000000 }],
+ cacheRead: [{ component: 'audio', price: 1, unit: 'token', quantity: 1000000 }],
+ cacheWrite: [{ component: 'video', price: 2, unit: 'token', quantity: 1000000 }],
+ },
+};
+const mixedComponents: ModelDisplayPricing = {
+ ...components,
+ summary: {
+ input: [
+ { component: 'text', price: 2, unit: 'token', quantity: 1000000 },
+ { component: 'image', price: 0.01, unit: 'image', quantity: 1, tier: 'HD' },
+ ],
+ },
+};
+const unknownComponent: ModelDisplayPricing = {
+ ...components,
+ summary: { input: [{ component: 'future_kind', price: 2, unit: 'token', quantity: 1000000 }] },
+};
+const labels: ModelDisplayPricing = {
+ items: [
+ 'Text Input', 'Text Output', 'Image Input', 'Image Output', 'Audio Input', 'Audio Output',
+ 'Video Input', 'Video Output', 'Text Cache Read', 'Text Cache Write', 'Image Cache Read',
+ 'Duration Input', 'Duration Output', 'Custom fee',
+ ].map(label => ({ label, price: 2, unit: 'request', quantity: 1 })),
+};
+
void mountPage({
host: {
maker: {
@@ -82,7 +117,7 @@ void mountPage({
render: (ctx) => {
const quote =
(
- { speech, image, video, mixed, compact, legacy: { items: speech.items } } as Record<
+ { speech, image, video, mixed, compact, components, 'mixed-components': mixedComponents, 'unknown-component': unknownComponent, labels, legacy: { items: speech.items } } as Record<
string,
ModelDisplayPricing
>
@@ -120,7 +155,7 @@ void mountPage({
name: 'Video',
mode: 'video_generation',
currency: 'CNY',
- costDiscount: 0.4,
+ costDiscount: ['components', 'mixed-components', 'unknown-component', 'labels'].includes(ctx.case) ? undefined : 0.4,
displayPricing: quote,
modalities: { input: ['text'], output: ['video'] },
},
diff --git a/apps/desktop/scripts/fixtures/display-pricing/ui-page.mjs b/apps/desktop/scripts/fixtures/display-pricing/ui-page.mjs
index ed7c83c6b4..fca303b6af 100644
--- a/apps/desktop/scripts/fixtures/display-pricing/ui-page.mjs
+++ b/apps/desktop/scripts/fixtures/display-pricing/ui-page.mjs
@@ -8,26 +8,34 @@ export default {
cases: {
speech: { about: 'Character input per million' },
image: { about: 'Input and output per image' },
- video: { about: 'Resolution tier with discounted range and starting price' },
+ video: { about: 'Video category with a resolution tier and discounted range' },
+ components: { about: 'Charge categories distinguish image tokens from text tokens' },
+ 'mixed-components': { about: 'Different categories in one role get per-quote prefixes' },
+ 'unknown-component': { about: 'Unknown categories fall back to the original direction' },
+ labels: { about: 'All published item labels are translated; custom labels are verbatim', viewport: { width: 800, height: 1600 } },
compact: { about: 'Short quotes stay on separate right-aligned rows' },
default: { about: 'Multiple units, all four roles and supplementary conditions' },
legacy: { about: 'Existing table without summary' },
},
async check(page, ui) {
+ const expectText = async text => {
+ if (!await page.getByText(text, { exact: true }).count()) throw Error(`Missing localized pricing text: ${text}`);
+ };
const pricing = page.getByText(await ui.t('settings.providers.models.advanced.pricing'), {
exact: true,
});
await pricing.scrollIntoViewIfNeeded();
- if (ui.case !== 'legacy') {
+ await ui.capture('pricing', { locator: pricing.locator('..').locator('..') });
+ if (!['legacy', 'labels'].includes(ui.case)) {
const role = ui.case === 'video' ? 'output' : 'input';
- await page
- .getByText(await ui.t(`settings.providers.models.advanced.price.${role}`), {
- exact: true,
- })
- .waitFor();
+ const component = { speech: 'text', image: 'image', video: 'video', components: 'text' }[ui.case];
+ const key = component
+ ? `newChat.modelSelector.displayPricing.roles.${component}.${role}`
+ : `settings.providers.models.advanced.price.${role}`;
+ await expectText(await ui.t(key));
}
const discount = page.getByText(await ui.t('settings.providers.models.advanced.discount'), { exact: true });
- if (['speech', 'image', 'legacy'].includes(ui.case)) {
+ if (['speech', 'image', 'legacy', 'components', 'mixed-components', 'unknown-component', 'labels'].includes(ui.case)) {
if (await discount.count()) throw Error('Unexpected discount on an undiscounted model');
} else {
await discount.waitFor();
@@ -54,7 +62,7 @@ export default {
}
// Browser regression: multiple quotes used to share a line with a separator.
// Check rendered positions so wrapping and right alignment hold across locales/themes.
- if (['default', 'compact'].includes(ui.case)) {
+ if (['default', 'compact', 'mixed-components'].includes(ui.case)) {
const layout = await page
.getByText(await ui.t('settings.providers.models.advanced.price.input'), { exact: true })
.evaluate(label => {
@@ -73,6 +81,27 @@ export default {
throw Error(`Multiple quotes must be separate right-aligned rows: ${JSON.stringify(layout)}`);
}
}
- await ui.capture('pricing');
+ if (ui.case === 'components') {
+ for (const [component, role] of [['text', 'input'], ['image', 'output'], ['audio', 'cacheRead'], ['video', 'cacheWrite']]) {
+ await expectText(await ui.t(`newChat.modelSelector.displayPricing.roles.${component}.${role}`));
+ }
+ }
+ if (ui.case === 'mixed-components') {
+ for (const component of ['text', 'image']) {
+ await expectText(await ui.t(`newChat.modelSelector.displayPricing.components.${component}`));
+ }
+ }
+ if (ui.case === 'unknown-component' && await page.getByText('future_kind', { exact: true }).count()) {
+ throw Error('Unknown category leaked into the quote label');
+ }
+ if (ui.case === 'labels') {
+ for (const component of ['text', 'image', 'audio', 'video']) {
+ for (const role of ['input', 'output']) {
+ await expectText(await ui.t(`newChat.modelSelector.displayPricing.roles.${component}.${role}`));
+ }
+ }
+ await expectText(await ui.t('newChat.modelSelector.displayPricing.durationOutput'));
+ await expectText('Custom fee');
+ }
},
};
diff --git a/apps/desktop/src/main/maker-host/__tests__/modelMetadataLayers.integration.test.ts b/apps/desktop/src/main/maker-host/__tests__/modelMetadataLayers.integration.test.ts
index 6f1962f375..03fb39fc1c 100644
--- a/apps/desktop/src/main/maker-host/__tests__/modelMetadataLayers.integration.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/modelMetadataLayers.integration.test.ts
@@ -587,7 +587,7 @@ describe('metadata layers through the active catalog', () => {
it('keeps complex quotes with their provider snapshot and clears them on successful replacement', () => {
- const displayPricing = { items: [{ label: 'Generated video', tier: 'HD', price: 0.5, unit: 'second', quantity: 1, priceType: 'estimated' as const }], notes: ['Billed by output duration.'], summary: { output: [{ price: 6, maxPrice: 10, unit: 'token', quantity: 1000000, tier: '480P/720P' }] } };
+ const displayPricing = { items: [{ label: 'Generated video', tier: 'HD', price: 0.5, unit: 'second', quantity: 1, priceType: 'estimated' as const }], notes: ['Billed by output duration.'], summary: { output: [{ price: 6, maxPrice: 10, unit: 'token', quantity: 1000000, tier: '480P/720P', component: 'video' }] } };
const video = { id: 'example-video', name: 'Video', mode: 'video_generation', agents: [] as const,
currency: 'USD' as const, costDiscount: 0.2, displayPricing,
modalities: { input: ['text'], output: ['video'] } };
diff --git a/apps/desktop/src/main/model-access/__tests__/mediaModels.test.ts b/apps/desktop/src/main/model-access/__tests__/mediaModels.test.ts
index c54d858ca3..4d936428f2 100644
--- a/apps/desktop/src/main/model-access/__tests__/mediaModels.test.ts
+++ b/apps/desktop/src/main/model-access/__tests__/mediaModels.test.ts
@@ -101,7 +101,7 @@ describe('listAvailableMediaModels', () => {
// Existing fixtures had no pricing; minimal regression is a Gateway image with one summary.output quote.
it('preserves the optional summary through media parsing and provider projection', async () => {
const displayPricing = { items: [{ label: 'Output', price: 0.3, unit: 'image', quantity: 1 }],
- summary: { input: [{ price: 0.02, unit: 'image', quantity: 1 }], output: [{ price: 0.3, unit: 'image', quantity: 1 }] } };
+ summary: { input: [{ price: 0.02, unit: 'image', quantity: 1, component: 'image' }], output: [{ price: 0.3, unit: 'image', quantity: 1, component: 'image' }] } };
serverApiFetchMock.mockResolvedValue({ ...payload, models: [{ ...payload.models[0], displayPricing, costDiscount: 0.2 }] });
await expect(listAvailableMediaModels()).resolves.toMatchObject([{ displayPricing, costDiscount: 0.2, currency: 'CNY', providerId: 'xd' }]);
});
diff --git a/apps/desktop/src/main/model-access/__tests__/modelsSyncRefresh.test.ts b/apps/desktop/src/main/model-access/__tests__/modelsSyncRefresh.test.ts
index 814365c2a3..2e4accb95d 100644
--- a/apps/desktop/src/main/model-access/__tests__/modelsSyncRefresh.test.ts
+++ b/apps/desktop/src/main/model-access/__tests__/modelsSyncRefresh.test.ts
@@ -36,7 +36,7 @@ describe('parseModelsSyncPayload', () => {
};
// Unit contract: refresh must preserve an optional summary, not only the existing table.
const quote = { items: [{ label: 'Output', price: 0.5, unit: 'second', quantity: 1 }], summary: {
- output: [{ price: 6, maxPrice: 10, unit: 'token', quantity: 1000000, tier: '480P/720P' }],
+ output: [{ price: 6, maxPrice: 10, unit: 'token', quantity: 1000000, tier: '480P/720P', component: 'video' }],
} };
const response = { schemaVersion: 5, accountTier: 'paid', models: [{ ...model, displayPricing: quote }] };
expect(parseModelsSyncPayload(response)).toMatchObject({ ok: true, models: [{ displayPricing: quote }] });
diff --git a/apps/desktop/src/renderer/components/DisplayPricingDetails.tsx b/apps/desktop/src/renderer/components/DisplayPricingDetails.tsx
index b09bcc1e9b..77fe9f108b 100644
--- a/apps/desktop/src/renderer/components/DisplayPricingDetails.tsx
+++ b/apps/desktop/src/renderer/components/DisplayPricingDetails.tsx
@@ -14,15 +14,34 @@ const UNIT_KEYS = {
megapixel_second: 'newChat.modelSelector.displayPricing.units.megapixelSecond',
} as const;
+// Only the published labels are localized. Provider-authored or future labels remain verbatim.
+const ITEM_LABEL_KEYS = {
+ 'Text Input': 'roles.text.input',
+ 'Text Output': 'roles.text.output',
+ 'Image Input': 'roles.image.input',
+ 'Image Output': 'roles.image.output',
+ 'Audio Input': 'roles.audio.input',
+ 'Audio Output': 'roles.audio.output',
+ 'Video Input': 'roles.video.input',
+ 'Video Output': 'roles.video.output',
+ 'Text Cache Read': 'roles.text.cacheRead',
+ 'Text Cache Write': 'roles.text.cacheWrite',
+ 'Image Cache Read': 'roles.image.cacheRead',
+ 'Duration Input': 'durationInput',
+ 'Duration Output': 'durationOutput',
+} as const;
+
/** Shared amount and denominator for both detailed items and primary summary quotes. */
export function DisplayPricingQuote({
quote,
currency,
costDiscount,
+ componentLabel,
}: {
quote: SummaryQuote | ModelDisplayPricing['items'][number];
currency: 'CNY' | 'USD';
costDiscount?: number;
+ componentLabel?: string;
}) {
const { t, i18n } = useTranslation();
const locale = i18n.resolvedLanguage ?? i18n.language;
@@ -49,6 +68,7 @@ export function DisplayPricingQuote({
<span className="inline-flex min-w-0 max-w-full flex-col gap-1 tabular-nums">
{quote.tier && <span className="break-words text-[var(--text-secondary)]">{quote.tier}</span>}
<span className="flex flex-wrap items-baseline justify-end gap-x-1.5 gap-y-1">
+ {componentLabel && <span className="whitespace-nowrap">{componentLabel}</span>}
<span className="whitespace-nowrap">{qualifiedPrice}</span>
{amount.original && <s className="whitespace-nowrap text-[var(--text-tertiary)]">{amount.original}</s>}
<span className="whitespace-nowrap text-[var(--text-tertiary)]">
@@ -61,6 +81,7 @@ export function DisplayPricingQuote({
/** Uses the selected source's snapshot, including currency and undiscounted amounts. */
export function DisplayPricingDetails({ model }: { model: PricingModel }) {
+ const { t } = useTranslation();
if (!model.displayPricing || !model.currency) return null;
const groups = new Map<string, ModelDisplayPricing['items']>();
for (const item of model.displayPricing.items) {
@@ -72,7 +93,11 @@ export function DisplayPricingDetails({ model }: { model: PricingModel }) {
<div className="space-y-3 text-12 text-[var(--text-secondary)]">
{Array.from(groups, ([label, items]) => (
<div key={label} className="space-y-1">
- <div className="break-words font-medium text-[var(--text-primary)]">{label}</div>
+ <div className="break-words font-medium text-[var(--text-primary)]">
+ {Object.hasOwn(ITEM_LABEL_KEYS, label)
+ ? t(`newChat.modelSelector.displayPricing.${ITEM_LABEL_KEYS[label as keyof typeof ITEM_LABEL_KEYS]}`)
+ : label}
+ </div>
{items.map((item, index) => (
<div
key={index}
diff --git a/apps/desktop/src/renderer/components/__tests__/DisplayPricingDetails.test.tsx b/apps/desktop/src/renderer/components/__tests__/DisplayPricingDetails.test.tsx
index a63c18428c..d26851f79b 100644
--- a/apps/desktop/src/renderer/components/__tests__/DisplayPricingDetails.test.tsx
+++ b/apps/desktop/src/renderer/components/__tests__/DisplayPricingDetails.test.tsx
@@ -82,6 +82,28 @@ describe('DisplayPricingDetails', () => {
);
describe.each(Object.keys(locales) as Array<keyof typeof locales>)('%s', locale => {
+ // Unit contract: the 13 published labels are localized; supplier text must not be guessed.
+ // Old cases only used custom labels. Render one item for each published label and two raw labels.
+ it('localizes published charge labels and preserves custom labels exactly', async () => {
+ const copy = locales[locale].newChat.modelSelector.displayPricing;
+ const labels = [
+ ['Text Input', copy.roles.text.input], ['Text Output', copy.roles.text.output],
+ ['Image Input', copy.roles.image.input], ['Image Output', copy.roles.image.output],
+ ['Audio Input', copy.roles.audio.input], ['Audio Output', copy.roles.audio.output],
+ ['Video Input', copy.roles.video.input], ['Video Output', copy.roles.video.output],
+ ['Text Cache Read', copy.roles.text.cacheRead], ['Text Cache Write', copy.roles.text.cacheWrite],
+ ['Image Cache Read', copy.roles.image.cacheRead],
+ ['Duration Input', copy.durationInput], ['Duration Output', copy.durationOutput],
+ ['Text input', 'Text input'], ['<b>Custom charge</b>', '<b>Custom charge</b>'],
+ ];
+ const { container } = await renderPricing({ currency: 'CNY', displayPricing: {
+ items: labels.map(([label]) => ({ ...item, label })),
+ } }, locale);
+ for (const [, expected] of labels) {
+ expect(screen.getAllByText(expected)).toHaveLength(labels.filter(([, text]) => text === expected).length);
+ }
+ expect(container.querySelector('b')).toBeNull();
+ });
it.each([{ price: 0, discount: 0 }, { price: 0.5, discount: 1 }])(
'shows neutral free wording for %j without implying a limited-time offer',
async ({ price, discount }) => {
diff --git a/apps/desktop/src/renderer/components/settings/ModelAdvancedDrawer.tsx b/apps/desktop/src/renderer/components/settings/ModelAdvancedDrawer.tsx
index 68ac7664a2..f160bc0d46 100644
--- a/apps/desktop/src/renderer/components/settings/ModelAdvancedDrawer.tsx
+++ b/apps/desktop/src/renderer/components/settings/ModelAdvancedDrawer.tsx
@@ -1,4 +1,4 @@
-import { isDisplayPricingTableRedundant } from '@/lib/displayPricingFormat';
+import { displayPricingComponent, isDisplayPricingTableRedundant } from '@/lib/displayPricingFormat';
import { DisplayPricingDetails, DisplayPricingQuote } from '@/components/DisplayPricingDetails';
import { Button } from '@/components/ui/button';
import { localizedModelDescription } from '@/lib/modelDescriptions';
@@ -1009,10 +1009,14 @@ export function ModelAdvancedDrawer({
{(['input', 'output', 'cacheRead', 'cacheWrite'] as const).map((role) => {
const quotes = primaryModel.displayPricing?.summary?.[role];
if (!quotes?.length) return null;
+ const components = quotes.map(quote => displayPricingComponent(quote.component));
+ const component = components.every(value => value === components[0]) ? components[0] : undefined;
return (
<Row
key={role}
- label={t(`settings.providers.models.advanced.price.${role === 'cacheWrite' ? 'cacheCreate' : role}`)}
+ label={component
+ ? t(`newChat.modelSelector.displayPricing.roles.${component}.${role}`)
+ : t(`settings.providers.models.advanced.price.${role === 'cacheWrite' ? 'cacheCreate' : role}`)}
>
<span className="flex flex-col items-end gap-1">
{quotes.map((quote, index) => (
@@ -1021,6 +1025,9 @@ export function ModelAdvancedDrawer({
quote={quote}
currency={primaryModel.currency!}
costDiscount={discount}
+ componentLabel={!component && components[index]
+ ? t(`newChat.modelSelector.displayPricing.components.${components[index]}`)
+ : undefined}
/>
))}
</span>
diff --git a/apps/desktop/src/renderer/components/settings/__tests__/ModelAdvancedDrawer.test.tsx b/apps/desktop/src/renderer/components/settings/__tests__/ModelAdvancedDrawer.test.tsx
index a42b01f741..45897b399f 100644
--- a/apps/desktop/src/renderer/components/settings/__tests__/ModelAdvancedDrawer.test.tsx
+++ b/apps/desktop/src/renderer/components/settings/__tests__/ModelAdvancedDrawer.test.tsx
@@ -810,6 +810,32 @@ it('keeps enterprise reference prices read-only in the model drawer', () => {
).toBeNull();
});
+// Component contract (unit): the real drawer names the charge, independently of its token unit.
+// Existing cases only name directions; one image quote and mixed/uncategorized variants cover fallback.
+it.each([
+ { components: ['image'], label: 'newChat.modelSelector.displayPricing.roles.image.output', prefixes: [] },
+ { components: ['image', 'image'], label: 'newChat.modelSelector.displayPricing.roles.image.output', prefixes: [] },
+ { components: [undefined], label: 'settings.providers.models.advanced.price.output', prefixes: [] },
+ { components: ['future_kind'], label: 'settings.providers.models.advanced.price.output', prefixes: [] },
+ { components: ['text', 'image'], label: 'settings.providers.models.advanced.price.output', prefixes: ['text', 'image'] },
+ { components: ['image', undefined], label: 'settings.providers.models.advanced.price.output', prefixes: ['image'] },
+])('labels primary quotes without inferring a category: $components', ({ components, label, prefixes }) => {
+ draw({ ...model, currency: 'CNY', displayPricing: {
+ items: [{ label: 'Custom fee', price: 1, unit: 'request', quantity: 1 }],
+ summary: { output: components.map((component, index) => ({
+ price: 840 + index, unit: 'token', quantity: 1000000, tier: index === 0 ? 'HD' : '4K', component,
+ })) },
+ } });
+ const row = screen.getByText(label).parentElement!;
+ expect(row.textContent).toContain('¥840');
+ expect(row.textContent).toContain('HD');
+ expect(row.textContent).not.toContain('future_kind');
+ for (const component of ['text', 'image', 'audio', 'video']) {
+ const prefix = `newChat.modelSelector.displayPricing.components.${component}`;
+ expect(row.textContent?.includes(prefix)).toBe(prefixes.includes(component));
+ }
+});
+
// Unit contract: drawer summary must show translated roles while retaining supplier conditions below.
// Previous drawer tests had no displayPricing; one input quote previously showed only the English table.
it.each([{ hasSummary: true, withNotes: true }, { hasSummary: true, withNotes: false }, { hasSummary: false, withNotes: false }])('keeps supplementary items when they do not match the summary: %j', ({ hasSummary, withNotes }) => {
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 1a714df768..95eac4bdd6 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -11546,6 +11546,40 @@
},
"modelSelector": {
"displayPricing": {
+ "components": {
+ "text": "Text",
+ "image": "Image",
+ "audio": "Audio",
+ "video": "Video"
+ },
+ "roles": {
+ "text": {
+ "input": "Text input",
+ "output": "Text output",
+ "cacheRead": "Text cache read",
+ "cacheWrite": "Text cache write"
+ },
+ "image": {
+ "input": "Image input",
+ "output": "Image output",
+ "cacheRead": "Image cache read",
+ "cacheWrite": "Image cache write"
+ },
+ "audio": {
+ "input": "Audio input",
+ "output": "Audio output",
+ "cacheRead": "Audio cache read",
+ "cacheWrite": "Audio cache write"
+ },
+ "video": {
+ "input": "Video input",
+ "output": "Video output",
+ "cacheRead": "Video cache read",
+ "cacheWrite": "Video cache write"
+ }
+ },
+ "durationInput": "Duration input",
+ "durationOutput": "Duration output",
"million": "1M",
"free": "Free",
"estimated": "About {{price}}",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 58be0e249a..8c4d17318a 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -11511,6 +11511,40 @@
},
"modelSelector": {
"displayPricing": {
+ "components": {
+ "text": "テキスト",
+ "image": "画像",
+ "audio": "音声",
+ "video": "動画"
+ },
+ "roles": {
+ "text": {
+ "input": "テキスト入力",
+ "output": "テキスト出力",
+ "cacheRead": "テキストキャッシュ読み取り",
+ "cacheWrite": "テキストキャッシュ書き込み"
+ },
+ "image": {
+ "input": "画像入力",
+ "output": "画像出力",
+ "cacheRead": "画像キャッシュ読み取り",
+ "cacheWrite": "画像キャッシュ書き込み"
+ },
+ "audio": {
+ "input": "音声入力",
+ "output": "音声出力",
+ "cacheRead": "音声キャッシュ読み取り",
+ "cacheWrite": "音声キャッシュ書き込み"
+ },
+ "video": {
+ "input": "動画入力",
+ "output": "動画出力",
+ "cacheRead": "動画キャッシュ読み取り",
+ "cacheWrite": "動画キャッシュ書き込み"
+ }
+ },
+ "durationInput": "入力時間",
+ "durationOutput": "出力時間",
"million": "100万",
"free": "無料",
"estimated": "約 {{price}}",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index fe735e14bf..9503739808 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -11511,6 +11511,40 @@
},
"modelSelector": {
"displayPricing": {
+ "components": {
+ "text": "텍스트",
+ "image": "이미지",
+ "audio": "오디오",
+ "video": "동영상"
+ },
+ "roles": {
+ "text": {
+ "input": "텍스트 입력",
+ "output": "텍스트 출력",
+ "cacheRead": "텍스트 캐시 읽기",
+ "cacheWrite": "텍스트 캐시 쓰기"
+ },
+ "image": {
+ "input": "이미지 입력",
+ "output": "이미지 출력",
+ "cacheRead": "이미지 캐시 읽기",
+ "cacheWrite": "이미지 캐시 쓰기"
+ },
+ "audio": {
+ "input": "오디오 입력",
+ "output": "오디오 출력",
+ "cacheRead": "오디오 캐시 읽기",
+ "cacheWrite": "오디오 캐시 쓰기"
+ },
+ "video": {
+ "input": "동영상 입력",
+ "output": "동영상 출력",
+ "cacheRead": "동영상 캐시 읽기",
+ "cacheWrite": "동영상 캐시 쓰기"
+ }
+ },
+ "durationInput": "입력 길이",
+ "durationOutput": "출력 길이",
"million": "100만",
"free": "무료",
"estimated": "약 {{price}}",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index fb7d12e903..6fad158919 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -11511,6 +11511,40 @@
},
"modelSelector": {
"displayPricing": {
+ "components": {
+ "text": "文字",
+ "image": "图片",
+ "audio": "音频",
+ "video": "视频"
+ },
+ "roles": {
+ "text": {
+ "input": "文字输入",
+ "output": "文字输出",
+ "cacheRead": "文字缓存读取",
+ "cacheWrite": "文字缓存写入"
+ },
+ "image": {
+ "input": "图片输入",
+ "output": "图片输出",
+ "cacheRead": "图片缓存读取",
+ "cacheWrite": "图片缓存写入"
+ },
+ "audio": {
+ "input": "音频输入",
+ "output": "音频输出",
+ "cacheRead": "音频缓存读取",
+ "cacheWrite": "音频缓存写入"
+ },
+ "video": {
+ "input": "视频输入",
+ "output": "视频输出",
+ "cacheRead": "视频缓存读取",
+ "cacheWrite": "视频缓存写入"
+ }
+ },
+ "durationInput": "时长输入",
+ "durationOutput": "时长输出",
"million": "百万",
"free": "免费",
"estimated": "约 {{price}}",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index b107446d26..9403a053ad 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -11511,6 +11511,40 @@
},
"modelSelector": {
"displayPricing": {
+ "components": {
+ "text": "文字",
+ "image": "圖片",
+ "audio": "音訊",
+ "video": "影片"
+ },
+ "roles": {
+ "text": {
+ "input": "文字輸入",
+ "output": "文字輸出",
+ "cacheRead": "文字快取讀取",
+ "cacheWrite": "文字快取寫入"
+ },
+ "image": {
+ "input": "圖片輸入",
+ "output": "圖片輸出",
+ "cacheRead": "圖片快取讀取",
+ "cacheWrite": "圖片快取寫入"
+ },
+ "audio": {
+ "input": "音訊輸入",
+ "output": "音訊輸出",
+ "cacheRead": "音訊快取讀取",
+ "cacheWrite": "音訊快取寫入"
+ },
+ "video": {
+ "input": "影片輸入",
+ "output": "影片輸出",
+ "cacheRead": "影片快取讀取",
+ "cacheWrite": "影片快取寫入"
+ }
+ },
+ "durationInput": "時長輸入",
+ "durationOutput": "時長輸出",
"million": "百萬",
"free": "免費",
"estimated": "約 {{price}}",
diff --git a/apps/desktop/src/renderer/lib/displayPricingFormat.ts b/apps/desktop/src/renderer/lib/displayPricingFormat.ts
index faef3009e1..57bbde0218 100644
--- a/apps/desktop/src/renderer/lib/displayPricingFormat.ts
+++ b/apps/desktop/src/renderer/lib/displayPricingFormat.ts
@@ -1,5 +1,12 @@
import type { ModelDisplayPricing, SummaryQuote } from '@cindy/model-providers';
+/** Unknown categories are ordinary uncategorized quotes, not inferred from their units. */
+export function displayPricingComponent(component: string | undefined) {
+ return component === 'text' || component === 'image' || component === 'audio' || component === 'video'
+ ? component
+ : undefined;
+}
+
/** Keep the quoted basis; do not convert mixed units or infer a model-wide starting price. */
export function displayPricingAmount(
item: Pick<SummaryQuote, 'price' | 'maxPrice'>,
diff --git a/docs/dev-rules/model-catalog-maintenance.md b/docs/dev-rules/model-catalog-maintenance.md
index f6f0937f4d..e48e719461 100644
--- a/docs/dev-rules/model-catalog-maintenance.md
+++ b/docs/dev-rules/model-catalog-maintenance.md
@@ -126,9 +126,14 @@ Desktop 设置页模型详情有 `displayPricing.summary` 时优先按输入、
所有角色报价段数,且每个 item 能按 unit、quantity、price 一一匹配不同的摘要报价,
匹配报价没有 maxPrice 或 tier。其余情况保留在摘要下方。设置页列表对带 displayPricing 的
模型不显示价格;选择器、浮层和聊天价格档位逻辑保持原样。详情中的有效折扣仍单列显示。
+摘要的可选 `component` 标明收费项类别,与计价单位独立。格式为 `^[a-z][a-z0-9_]{0,31}$`;
+格式不合法只丢该字段,报价与摘要保留。合法但未知的类别保留在数据中,界面按缺失处理。
+已知类别为 text / image / audio / video:同一角色类别一致时显示「类别 + 方向」,混合类别时
+保留方向名并在各条报价金额前显示已知类别名;不从单位推断类别。唯一键沿用
+unit + quantity + tier,不加入 component;旧端忽略新增字段,协议版本不变。
摘要的 tier 单独一行使用次要文字,金额、原价区间和单位分别保持完整,同一角色的多段报价逐条换行、靠右对齐,不插入分隔点。
`price` / `maxPrice` 为每 `quantity` 个 `unit` 的折扣前报价,只在展示时应用一次折扣,保留币种
-与“约”的语义;items 另外保留“起价”语义。角色和已知单位本地化,label、tier、notes 仅按纯文本呈现,未知单位不猜换算。
+与“约”的语义;items 另外保留“起价”语义。角色和已知单位本地化;已发布的 Text / Image / Audio / Video 输入输出、Text 缓存读写、Image 缓存读取及 Duration 输入输出明细 label 本地化,其他 label、tier、notes 原样按纯文本呈现,未知单位不猜换算。
数量 1 省略,百万按语言简写,其余按本地数字格式显示。共享目录可传递这些可选展示字段,旧端
缺字段仍合法,不新增能力声明;此 UI 仅覆盖 Desktop 设置页。解析与展示回归见
`modelDisplayPricing.test.ts`、`DisplayPricingDetails.test.tsx` 与 `ModelAdvancedDrawer.test.tsx`。
diff --git a/i18n/GLOSSARY.md b/i18n/GLOSSARY.md
index 480b44c5e5..ffe220bf60 100644
--- a/i18n/GLOSSARY.md
+++ b/i18n/GLOSSARY.md
@@ -511,6 +511,26 @@ Plugin 声明的应用级完整页面能力;区别于会话内 Panel。V1 由
插件随包提供、由 ghost_manual 按需读取的渐进披露长文资料。它不是权限项,也不等同于已停止新增的 Agent Skill;先登记为 proposed,待插件作者与用户实际使用后再固化。
+### Audio
+
+模型报价中的收费项类别,不是计价单位;用于类别名及类别与输入、输出、缓存读写的组合名称。
+
+### Image
+
+模型报价中的收费项类别,不是计价单位;用于类别名及类别与输入、输出、缓存读写的组合名称。
+
+### Text
+
+模型报价中的收费项类别,不是计价单位;用于类别名及类别与输入、输出、缓存读写的组合名称。
+
+### Video
+
+模型报价中的收费项类别,不是计价单位;用于类别名及类别与输入、输出、缓存读写的组合名称。
+
+### Duration
+
+模型价目表的时长收费项:Duration Input / Duration Output;不是请求耗时。
+
### Process
OS 进程语境(资源用量面板、浏览器 guest 进程、终端)。注意与 Thread→任务(消息流语境)区分:资源用量面板刻意不展示 OS 线程数,避免「线程」撞上 Thread 的既定裁决;若未来要展示,需为 OS thread 立同形异义条目再谈。
diff --git a/i18n/glossary.json b/i18n/glossary.json
index 4e635033fb..ebde674565 100644
--- a/i18n/glossary.json
+++ b/i18n/glossary.json
@@ -5,6 +5,11 @@
"sourceLocale": "en",
"punctuationExempt": ["desktop:settings.help.qnaFeedbackBodyTemplate"],
"terms": [
+ {"id": "pricing-component-text", "status": "proposed", "en": "Text", "translations": {"zh-CN": "文字", "zh-TW": "文字", "ja": "テキスト", "ko": "텍스트"}, "note": "模型报价中的收费项类别,不是计价单位;用于类别名及类别与输入、输出、缓存读写的组合名称。"},
+ {"id": "pricing-component-image", "status": "proposed", "en": "Image", "translations": {"zh-CN": "图片", "zh-TW": "圖片", "ja": "画像", "ko": "이미지"}, "note": "模型报价中的收费项类别,不是计价单位;用于类别名及类别与输入、输出、缓存读写的组合名称。"},
+ {"id": "pricing-component-audio", "status": "proposed", "en": "Audio", "translations": {"zh-CN": "音频", "zh-TW": "音訊", "ja": "音声", "ko": "오디오"}, "note": "模型报价中的收费项类别,不是计价单位;用于类别名及类别与输入、输出、缓存读写的组合名称。"},
+ {"id": "pricing-component-video", "status": "proposed", "en": "Video", "translations": {"zh-CN": "视频", "zh-TW": "影片", "ja": "動画", "ko": "동영상"}, "note": "模型报价中的收费项类别,不是计价单位;用于类别名及类别与输入、输出、缓存读写的组合名称。"},
+ {"id": "pricing-duration", "status": "proposed", "en": "Duration", "translations": {"zh-CN": "时长", "zh-TW": "時長", "ja": "時間", "ko": "길이"}, "note": "模型价目表的时长收费项:Duration Input / Duration Output;不是请求耗时。"},
{"id":"scrolling-screenshot","status":"proposed","en":"Scrolling Screenshot","translations":{"zh-CN":"滚动截图","zh-TW":"捲動截圖","ja":"スクロールスクリーンショット","ko":"스크롤 스크린샷"},"checkCase":false,"note":"2026-10-26 用户指定截图功能统一称为滚动截图,突出滚动操作,不再使用长截图作为功能名称。"},
{"id": "archive-task", "status": "proposed", "en": "Archive", "translations": {"zh-CN": "归档", "zh-TW": "歸檔", "ja": "アーカイブ", "ko": "보관"}, "checkCase": false, "note": "任务归档动作。灵动岛完成卡按钮沿用既有任务归档确认框的译法,避免同一操作链路混用存档/归档或封存/歸檔;不在此条目裁决或批量修改其它语境。"},
{"id": "speech-speed", "status": "proposed", "en": "Speech speed", "translations": {"zh-CN": "语速", "zh-TW": "語速", "ja": "読み上げ速度", "ko": "읽기 속도"}, "checkCase": false, "note": "伙伴语音设置的合成语速;按伙伴保存,通话朗读、消息朗读和试听共用。区别于播放器倍速和语音输入停顿时间。"},
diff --git a/packages/model-providers/src/__tests__/modelDisplayPricing.test.ts b/packages/model-providers/src/__tests__/modelDisplayPricing.test.ts
index 90839f6669..a91c3d2889 100644
--- a/packages/model-providers/src/__tests__/modelDisplayPricing.test.ts
+++ b/packages/model-providers/src/__tests__/modelDisplayPricing.test.ts
@@ -72,6 +72,27 @@ describe("display pricing contract", () => {
// Minimum input: one summary.input quote. Invalid roles must drop the summary, preserving the full table.
describe("optional primary quote summary", () => {
const quote = { price: 0, unit: "image", quantity: 1 };
+ // Unit contract: component is an optional hint, never a reason to lose a quote or table.
+ // Earlier parser cases had no category; one input quote exercises preservation and field-only fallback.
+ it.each(["text", "image", "audio", "video", "future_type2", "a".repeat(32)])(
+ "preserves a valid component identifier: %s", (component) => {
+ const summary = { input: [{ ...quote, component }] };
+ expect(parseModelDisplayPricing({ ...table, summary })).toEqual({ ...table, summary });
+ },
+ );
+ it.each([undefined, null, "", "Text", "text-input", "text\n", "a".repeat(33), 42, {}, []])(
+ "drops only an invalid or absent component: %j", (component) => {
+ expect(parseModelDisplayPricing({ ...table, summary: { input: [{ ...quote, component }] } }))
+ .toEqual({ ...table, summary: { input: [quote] } });
+ },
+ );
+ it("does not add component to the quote uniqueness key or item fields", () => {
+ expect(parseModelDisplayPricing({ ...table, summary: {
+ input: [{ ...quote, component: "text" }, { ...quote, component: "image" }],
+ } })).toEqual(table);
+ expect(parseModelDisplayPricing({ items: [{ ...table.items[0], component: "video" }] }))
+ .toEqual({ items: table.items });
+ });
it("preserves all roles, ranges, units and conditions but strips unknown fields", () => {
const summary = {
input: [quote, { price: 140, unit: "character", quantity: 1000000 }],
diff --git a/packages/model-providers/src/modelDisplayPricing.ts b/packages/model-providers/src/modelDisplayPricing.ts
index 276604525c..c2ce1facde 100644
--- a/packages/model-providers/src/modelDisplayPricing.ts
+++ b/packages/model-providers/src/modelDisplayPricing.ts
@@ -4,6 +4,8 @@ export interface SummaryQuote {
maxPrice?: number;
unit: string;
quantity: number;
+ /** Optional charge category; unknown identifiers are retained for forward compatibility. */
+ component?: string;
tier?: string;
priceType?: "exact" | "estimated";
}
@@ -105,6 +107,10 @@ function parseSummary(value: unknown): ModelDisplayPricingSummary | undefined {
}
result.push({
...fields,
+ // A malformed optional category must never discard an otherwise valid quote.
+ ...(typeof quote.component === "string" && /^[a-z][a-z0-9_]{0,31}$/.test(quote.component)
+ ? { component: quote.component }
+ : {}),
...(priceType !== undefined ? { priceType } : {}),
...(maxPrice !== undefined ? { maxPrice } : {}),
});