Skip to content

Commit 3be752a

Browse files
committed
fix(models): align metadata pricing and benchmark labels
1 parent 95d8bc9 commit 3be752a

2 files changed

Lines changed: 23 additions & 14 deletions

File tree

src/components/product/ModelBenchmarks.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface ModelBenchmarksProps {
1313
*/
1414
export function ModelBenchmarks({ benchmarks }: ModelBenchmarksProps) {
1515
const tComponent = useTranslations('components.product')
16+
const tShared = useTranslations('shared')
1617
if (!benchmarks || !hasBenchmarks(benchmarks)) {
1718
return null
1819
}
@@ -32,12 +33,14 @@ export function ModelBenchmarks({ benchmarks }: ModelBenchmarksProps) {
3233
return (
3334
<div key={key} className="border border-[var(--color-border)] p-[var(--spacing-md)]">
3435
<h3 className="text-xs text-[var(--color-text-muted)] uppercase tracking-wider font-medium mb-[var(--spacing-xs)]">
35-
{tComponent(`${key}`)}
36+
{tShared(`benchmarks.${key}`)}
3637
</h3>
3738
<p className="text-lg font-semibold tracking-tight mb-1">
3839
{formatBenchmarkValue(key, value)}
3940
</p>
40-
<p className="text-xs text-[var(--color-text-muted)]">{tComponent(`${key}Desc`)}</p>
41+
<p className="text-xs text-[var(--color-text-muted)]">
42+
{tComponent(`benchmarks.${key}Desc`)}
43+
</p>
4144
</div>
4245
)
4346
})}

src/lib/metadata/schemas/generators.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import { getTranslations } from 'next-intl/server'
88
import { cache } from 'react'
99
import type { Locale } from '@/i18n/config'
10+
import { getPrimaryTokenPricingOffer, hasCurrentSingleTierPricing } from '@/lib/model-pricing'
11+
import type { ManifestTokenPricing, ModelLifecycle } from '@/types/manifests'
1012
import { SITE_CONFIG } from '../config'
1113
import {
1214
type ArticleSchemaOptions,
@@ -100,11 +102,8 @@ export interface ModelData {
100102
vendor: string
101103
vendorUrl?: string
102104
websiteUrl?: string
103-
tokenPricing?: {
104-
input?: number
105-
output?: number
106-
cache?: number
107-
}
105+
lifecycle?: ModelLifecycle
106+
tokenPricing?: ManifestTokenPricing
108107
}
109108

110109
/**
@@ -123,21 +122,28 @@ export const generateModelDetailSchema = cache(
123122
async (options: ModelDetailSchemaOptions): Promise<SchemaProduct> => {
124123
const { model } = options
125124

126-
// Transform token pricing to pricing tiers
125+
// Only publish unambiguous current, single-tier prices as Schema.org offers.
127126
const pricing: PricingTierData[] = []
128-
if (model.tokenPricing?.input) {
127+
const offer = model.tokenPricing ? getPrimaryTokenPricingOffer(model.tokenPricing) : null
128+
const rates =
129+
model.lifecycle !== 'deprecated' &&
130+
model.tokenPricing &&
131+
hasCurrentSingleTierPricing(model.tokenPricing)
132+
? offer?.tiers[0]?.rates
133+
: null
134+
if (offer && rates?.input !== null && rates?.input !== undefined) {
129135
pricing.push({
130136
name: 'Input Tokens',
131-
value: model.tokenPricing.input,
132-
currency: 'USD',
137+
value: rates.input,
138+
currency: offer.currency,
133139
per: 'million tokens',
134140
})
135141
}
136-
if (model.tokenPricing?.output) {
142+
if (offer && rates?.output !== null && rates?.output !== undefined) {
137143
pricing.push({
138144
name: 'Output Tokens',
139-
value: model.tokenPricing.output,
140-
currency: 'USD',
145+
value: rates.output,
146+
currency: offer.currency,
141147
per: 'million tokens',
142148
})
143149
}

0 commit comments

Comments
 (0)