From 475b408119fc1dad4ecabbc37ed9e0fe45d00df3 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 4 Sep 2026 18:41:12 +0800 Subject: [PATCH 01/25] fix(console): backport usage reset boundary fix to dev (#47267) --- .../app/src/routes/zen/util/handler.ts | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/packages/console/app/src/routes/zen/util/handler.ts b/packages/console/app/src/routes/zen/util/handler.ts index b1aa6fe74a67..87fc93e7a928 100644 --- a/packages/console/app/src/routes/zen/util/handler.ts +++ b/packages/console/app/src/routes/zen/util/handler.ts @@ -1078,6 +1078,8 @@ export async function handler( authInfo = authInfo! const cost = centsToMicroCents(totalCostInCent) + // Keep period bounds and persisted timestamps on one snapshot when a queued write crosses a reset boundary. + const trackedAt = new Date() // For hot workspaces, batch balance/usage updates through Redis to avoid // row-level lock contention on BillingTable/UserTable. Returns the amount @@ -1118,7 +1120,7 @@ export async function handler( if (billingSource === "subscription") { const plan = authInfo.billing.subscription!.plan const black = BlackData.getLimits({ plan }) - const week = getWeekBounds(new Date()) + const week = getWeekBounds(trackedAt) const rollingWindowSeconds = black.rollingWindow * 3600 return [ db @@ -1126,11 +1128,17 @@ export async function handler( .set({ fixedUsage: sql` CASE + WHEN ${SubscriptionTable.timeFixedUpdated} >= ${week.end} THEN ${SubscriptionTable.fixedUsage} WHEN ${SubscriptionTable.timeFixedUpdated} >= ${week.start} THEN ${SubscriptionTable.fixedUsage} + ${cost} ELSE ${cost} END `, - timeFixedUpdated: sql`now()`, + timeFixedUpdated: sql` + CASE + WHEN ${SubscriptionTable.timeFixedUpdated} > ${trackedAt} THEN ${SubscriptionTable.timeFixedUpdated} + ELSE ${trackedAt} + END + `, rollingUsage: sql` CASE WHEN UNIX_TIMESTAMP(${SubscriptionTable.timeRollingUpdated}) >= UNIX_TIMESTAMP(now()) - ${rollingWindowSeconds} THEN ${SubscriptionTable.rollingUsage} + ${cost} @@ -1154,8 +1162,8 @@ export async function handler( } if (billingSource === "lite") { const lite = LiteData.getLimits() - const week = getWeekBounds(new Date()) - const month = getMonthlyBounds(new Date(), authInfo.lite!.timeCreated) + const week = getWeekBounds(trackedAt) + const month = getMonthlyBounds(trackedAt, authInfo.lite!.timeCreated) const rollingWindowSeconds = lite.rollingWindow * 3600 const quotaCost = Math.round(cost * modelInfo.costMultiplier) return [ @@ -1164,18 +1172,30 @@ export async function handler( .set({ monthlyUsage: sql` CASE + WHEN ${LiteTable.timeMonthlyUpdated} >= ${month.end} THEN ${LiteTable.monthlyUsage} WHEN ${LiteTable.timeMonthlyUpdated} >= ${month.start} THEN ${LiteTable.monthlyUsage} + ${quotaCost} ELSE ${quotaCost} END `, - timeMonthlyUpdated: sql`now()`, + timeMonthlyUpdated: sql` + CASE + WHEN ${LiteTable.timeMonthlyUpdated} > ${trackedAt} THEN ${LiteTable.timeMonthlyUpdated} + ELSE ${trackedAt} + END + `, weeklyUsage: sql` CASE + WHEN ${LiteTable.timeWeeklyUpdated} >= ${week.end} THEN ${LiteTable.weeklyUsage} WHEN ${LiteTable.timeWeeklyUpdated} >= ${week.start} THEN ${LiteTable.weeklyUsage} + ${quotaCost} ELSE ${quotaCost} END `, - timeWeeklyUpdated: sql`now()`, + timeWeeklyUpdated: sql` + CASE + WHEN ${LiteTable.timeWeeklyUpdated} > ${trackedAt} THEN ${LiteTable.timeWeeklyUpdated} + ELSE ${trackedAt} + END + `, rollingUsage: sql` CASE WHEN UNIX_TIMESTAMP(${LiteTable.timeRollingUpdated}) >= UNIX_TIMESTAMP(now()) - ${rollingWindowSeconds} THEN ${LiteTable.rollingUsage} + ${quotaCost} From 3f311390647337d0ddaeeb9be45ede8e5f468209 Mon Sep 17 00:00:00 2001 From: Victor Navarro Date: Fri, 4 Sep 2026 12:42:58 +0200 Subject: [PATCH 02/25] feat(console): route migrated BYOK through provider connections (#47266) --- .../console/app/src/lib/inference-proxy.ts | 51 ++++++++++++++++--- packages/console/app/src/middleware.ts | 8 --- .../app/src/routes/zen/util/handler.ts | 22 +++++++- .../console/app/src/routes/zen/v1/models.ts | 36 ++++++++++++- 4 files changed, 100 insertions(+), 17 deletions(-) diff --git a/packages/console/app/src/lib/inference-proxy.ts b/packages/console/app/src/lib/inference-proxy.ts index 814cc94552db..7de73a961ac8 100644 --- a/packages/console/app/src/lib/inference-proxy.ts +++ b/packages/console/app/src/lib/inference-proxy.ts @@ -1,16 +1,24 @@ import { Resource } from "@opencode-ai/console-resource" -import { Database, eq } from "@opencode-ai/console-core/drizzle/index.js" +import { and, Database, eq, isNull, sql } from "@opencode-ai/console-core/drizzle/index.js" import { KeyTable } from "@opencode-ai/console-core/schema/key.sql.js" +import { ProviderTable } from "@opencode-ai/console-core/schema/provider.sql.js" import { WorkspaceTable } from "@opencode-ai/console-core/schema/workspace.sql.js" const paths: Record = { - "GET /zen/v1/models": "/v1/models", "POST /zen/v1/chat/completions": "/openai/v1/chat/completions", "POST /zen/v1/responses": "/openai/v1/responses", "POST /zen/v1/messages": "/anthropic/v1/messages", } -export async function proxyInference(request: Request, clientIP?: string): Promise { +export async function proxyInference( + request: Request, + generation: { + provider?: "openai" | "anthropic" | "google" + /** The provider's native model ID, not the public Zen alias. */ + model?: string + body: (model?: string) => ReadableStream + }, +): Promise { const url = new URL(request.url) const path = paths[`${request.method} ${url.pathname}`] ?? @@ -30,23 +38,52 @@ export async function proxyInference(request: Request, clientIP?: string): Promi // Routing only; the destination owns authentication and revocation after cutover. const workspace = await Database.use((tx) => tx - .select({ migratedAt: WorkspaceTable.migrated_at }) + .select({ + id: WorkspaceTable.id, + migratedAt: WorkspaceTable.migrated_at, + provider: ProviderTable.provider, + }) .from(KeyTable) .innerJoin(WorkspaceTable, eq(WorkspaceTable.id, KeyTable.workspaceID)) + .leftJoin( + ProviderTable, + generation.provider + ? and( + eq(ProviderTable.workspaceID, KeyTable.workspaceID), + eq(ProviderTable.provider, generation.provider), + isNull(ProviderTable.timeDeleted), + sql`length(${ProviderTable.credentials}) > 0`, + ) + : sql`false`, + ) .where(eq(KeyTable.key, key)) .limit(1) .then((rows) => rows[0]), ) if (!workspace?.migratedAt) return undefined + const model = workspace.provider ? generation.model : undefined + if (workspace.provider && !model) throw new Error("Legacy BYOK model mapping is unavailable") const destination = new URL(Resource.ConsoleMigration.inferenceUrl) - destination.pathname = `${destination.pathname.replace(/\/$/, "")}${path}` + // Imported connections must use this same workspace/provider-derived ID. + const target = model + ? `/custom/conn_${workspace.id.slice(4)}_${workspace.provider}${ + path.startsWith("/google/") + ? `/models/${encodeURIComponent(model)}${url.pathname.slice(url.pathname.lastIndexOf(":"))}` + : url.pathname.slice("/zen/v1".length) + }` + : path + destination.pathname = `${destination.pathname.replace(/\/$/, "")}${target}` destination.search = url.search destination.hash = "" - const forwarded = new Request(destination, request) + // Model extraction has already read part of the body; forward its replay stream. + const forwarded = new Request( + destination, + new Request(request, { method: request.method, body: generation.body(model) }), + ) forwarded.headers.set("authorization", `Bearer ${key}`) - const ip = request.headers.get("cf-connecting-ip") ?? clientIP + const ip = request.headers.get("cf-connecting-ip") if (ip) forwarded.headers.set("x-real-ip", ip) const requestID = request.headers.get("x-opencode-request-id") ?? request.headers.get("x-opencode-request") if (requestID) forwarded.headers.set("x-opencode-request-id", requestID) diff --git a/packages/console/app/src/middleware.ts b/packages/console/app/src/middleware.ts index e768afa4f37f..614cc87bcf00 100644 --- a/packages/console/app/src/middleware.ts +++ b/packages/console/app/src/middleware.ts @@ -2,7 +2,6 @@ import { createMiddleware } from "@solidjs/start/middleware" import { LOCALE_HEADER, cookie, fromPathname, strip } from "~/lib/language" import { normalizeReferralCode, referralCookie } from "~/lib/referral-invite" import { sanitizeServerActionRequest } from "~/lib/server-action" -import { proxyInference } from "~/lib/inference-proxy" export default createMiddleware({ async onRequest(event) { @@ -20,12 +19,5 @@ export default createMiddleware({ const referralCode = normalizeReferralCode(url.searchParams.get("ref")) if (referralCode) event.response.headers.append("set-cookie", referralCookie(referralCode)) - - return proxyInference(event.request, event.clientAddress).catch(() => - Response.json( - { error: { type: "api_error", message: "Inference routing is unavailable. Please retry later." } }, - { status: 503, headers: { "Cache-Control": "no-store" } }, - ), - ) }, }) diff --git a/packages/console/app/src/routes/zen/util/handler.ts b/packages/console/app/src/routes/zen/util/handler.ts index 87fc93e7a928..adbfdecc890f 100644 --- a/packages/console/app/src/routes/zen/util/handler.ts +++ b/packages/console/app/src/routes/zen/util/handler.ts @@ -50,6 +50,7 @@ import { countryFromRequest, isModelCountryRestricted } from "~/lib/request-coun import { isPeakPricing } from "./pricing" import { prepareRequestBody } from "./requestBody" import { requiresGoTrainingConsent } from "./trainingConsent" +import { proxyInference } from "~/lib/inference-proxy" type ZenData = Awaited> type PreparedBody = Awaited> @@ -100,6 +101,26 @@ export async function handler( const ip = rawIp.includes(":") ? rawIp.split(":").slice(0, 4).join(":") : rawIp const rawZenApiKey = opts.parseApiKey(input.request.headers) const zenApiKey = rawZenApiKey === "public" ? undefined : rawZenApiKey + const zenData = ZenData.list(opts.modelList) + if (opts.modelList === "full" && model) { + // Read routing metadata without running legacy model, auth, or balance checks. + const configured = zenData.models[model] + const entry = Array.isArray(configured) + ? configured.find((entry) => entry.formatFilter === opts.format) + : configured + const response = await proxyInference(input.request, { + provider: entry?.byokProvider, + model: entry?.providers.find((provider) => provider.id === entry.byokProvider)?.model, + body: (providerModel) => requestBody?.stream(providerModel ?? model, false) ?? body, + }).catch(() => { + void (requestBody ? requestBody.cancel() : body.cancel()).catch(() => {}) + return Response.json( + { error: { type: "api_error", message: "Inference routing is unavailable. Please retry later." } }, + { status: 503, headers: { "Cache-Control": "no-store" } }, + ) + }) + if (response) return response + } const sessionId = input.request.headers.get("x-opencode-session") ?? "" const requestId = input.request.headers.get("x-opencode-request") ?? "" const ocClient = input.request.headers.get("x-opencode-client") ?? "" @@ -112,7 +133,6 @@ export async function handler( user_agent: userAgent, "model.tier": opts.modelList === "full" ? "zen" : "go", }) - const zenData = ZenData.list(opts.modelList) const modelInfo = validateModel(zenData, model) const country = countryFromRequest(input.request) if (isModelCountryRestricted(modelInfo.id, country)) throw new RegionError(t("zen.api.error.countryNotAllowed")) diff --git a/packages/console/app/src/routes/zen/v1/models.ts b/packages/console/app/src/routes/zen/v1/models.ts index 68c3cac69467..262a1bb349fe 100644 --- a/packages/console/app/src/routes/zen/v1/models.ts +++ b/packages/console/app/src/routes/zen/v1/models.ts @@ -5,14 +5,25 @@ import { KeyTable } from "@opencode-ai/console-core/schema/key.sql.js" import { WorkspaceTable } from "@opencode-ai/console-core/schema/workspace.sql.js" import { ModelTable } from "@opencode-ai/console-core/schema/model.sql.js" import { buildOptionsResponse, buildModelsResponse } from "~/routes/zen/util/modelsHandler" +import { Resource } from "@opencode-ai/console-resource" export async function OPTIONS(_input: APIEvent) { return buildOptionsResponse() } export async function GET(input: APIEvent) { + const apiKey = input.request.headers.get("authorization")?.split(" ")[1] + if (apiKey && apiKey !== "public") { + const response = await proxyModels(input, apiKey).catch(() => + Response.json( + { error: { type: "api_error", message: "Inference routing is unavailable. Please retry later." } }, + { status: 503, headers: { "Cache-Control": "no-store" } }, + ), + ) + if (response) return response + } + const disabledModels = await (() => { - const apiKey = input.request.headers.get("authorization")?.split(" ")[1] if (!apiKey) return [] as string[] return Database.use((tx) => @@ -34,3 +45,26 @@ export async function GET(input: APIEvent) { return buildModelsResponse(models) } + +async function proxyModels(input: APIEvent, apiKey: string) { + // No legacy revocation or model-policy checks before destination authentication. + const workspace = await Database.use((tx) => + tx + .select({ migratedAt: WorkspaceTable.migrated_at }) + .from(KeyTable) + .innerJoin(WorkspaceTable, eq(WorkspaceTable.id, KeyTable.workspaceID)) + .where(eq(KeyTable.key, apiKey)) + .limit(1) + .then((rows) => rows[0]), + ) + if (!workspace?.migratedAt) return undefined + + const destination = new URL(Resource.ConsoleMigration.inferenceUrl) + destination.pathname = `${destination.pathname.replace(/\/$/, "")}/v1/models` + destination.search = new URL(input.request.url).search + destination.hash = "" + const headers = new Headers({ authorization: `Bearer ${apiKey}` }) + const ip = input.request.headers.get("cf-connecting-ip") + if (ip) headers.set("x-real-ip", ip) + return fetch(destination, { headers, signal: input.request.signal, redirect: "manual" }) +} From 4178fd74f126ce791bcf8fc8c73d6e5de947ae6a Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Fri, 4 Sep 2026 07:32:58 -0500 Subject: [PATCH 03/25] fix(stats): hide stealth model providers --- .../src/component/model-compare-detail.tsx | 50 ++++++--- .../stats/app/src/routes/[lab]/[model].tsx | 103 +++++++++++------- .../stats/app/src/routes/compare-cards.tsx | 35 +++--- .../stats/app/src/routes/compare-radar.tsx | 4 +- packages/stats/app/src/routes/index.css | 8 ++ packages/stats/app/src/routes/index.tsx | 49 +++++++-- .../stats/app/src/routes/model-catalog.ts | 10 ++ 7 files changed, 176 insertions(+), 83 deletions(-) diff --git a/packages/stats/app/src/component/model-compare-detail.tsx b/packages/stats/app/src/component/model-compare-detail.tsx index 4966d5d45314..fa82ea4952db 100644 --- a/packages/stats/app/src/component/model-compare-detail.tsx +++ b/packages/stats/app/src/component/model-compare-detail.tsx @@ -24,6 +24,8 @@ import { findModelCatalogEntry, formatCatalogLabName, getModelCatalog, + isKnownCatalogLab, + isProviderlessLab, type ModelCatalog, type ModelCatalogEntry, } from "../routes/model-catalog" @@ -71,7 +73,7 @@ const comparisonModelLimit = 6 type ComparisonModel = { name: string lab: string - labName: string + labName?: string slug: string catalog: ModelCatalogEntry | null stats: StatsModelComparisonEntry | null @@ -159,13 +161,19 @@ export default function ModelCompareDetailPage(props: ModelCompareDetailPageProp let comparisonBodyScroll: HTMLDivElement | undefined const models = createMemo(() => modelSelections().map((model, index) => - buildComparisonModel(model.lab, model.slug, model.catalog ?? null, stats()?.models[index] ?? null), + buildComparisonModel( + model.lab, + model.slug, + model.catalog ?? null, + stats()?.models[index] ?? null, + catalog()?.labs.map((lab) => lab.id) ?? [], + ), ), ) const title = createMemo(() => `${models()[0].name} vs ${models()[1].name} - AI Model Comparison`) const description = createMemo( () => - `Compare ${models()[0].name} from ${models()[0].labName} and ${models()[1].name} from ${models()[1].labName} on key metrics including benchmarks, price, context length, usage, and model features.`, + `Compare ${comparisonModelLabel(models()[0])} and ${comparisonModelLabel(models()[1])} on key metrics including benchmarks, price, context length, usage, and model features.`, ) const canonicalPath = createMemo(() => { if (props.family) return canonicalFamilyComparisonPath(props.family.first, props.family.second) @@ -206,7 +214,7 @@ export default function ModelCompareDetailPage(props: ModelCompareDetailPageProp "@type": "SoftwareApplication", name: model.name, applicationCategory: "AI model", - provider: model.labName, + ...(model.labName ? { provider: model.labName } : {}), })), }), ) @@ -459,7 +467,9 @@ function CompareDetailSelectButton(props: { aria-expanded={props.expanded} onClick={props.onOpen} > - + + {(labName) => } + {props.model.name} @@ -581,8 +591,7 @@ function CompareModelDetail(props: { model: ModelCatalogEntry }) {

- {props.model.description ?? - `${props.model.name} is an AI model from ${formatCatalogLabName(props.model.lab)}.`} + {props.model.description ?? `${props.model.name} is an AI model.`}

@@ -789,9 +798,11 @@ function LabLogo(props: { lab: string; label: string; size: "large" | "small" | const iconId = () => getProviderIconId(props.lab) return ( - - + + + + ) } @@ -832,11 +843,13 @@ function buildComparisonModel( modelParam: string, catalog: ModelCatalogEntry | null, stats: StatsModelComparisonEntry | null, + catalogLabs: readonly string[], ): ComparisonModel { + const lab = catalog?.lab ?? stats?.provider ?? catalogSlug(labParam) return { name: catalog?.name ?? stats?.model ?? formatParamName(modelParam), - lab: catalog?.lab ?? stats?.provider ?? catalogSlug(labParam), - labName: formatCatalogLabName(catalog?.lab ?? stats?.provider ?? labParam), + lab, + labName: isKnownCatalogLab(lab, catalogLabs) ? formatCatalogLabName(lab) : undefined, slug: catalog?.slug ?? stats?.slug ?? catalogSlug(modelParam), catalog, stats, @@ -877,7 +890,7 @@ function buildComparisonDetailSections(models: readonly ComparisonModel[]): Comp rows: [ comparisonDetailRow( "Author", - models.map((model) => linkedTextCell(model.stats?.author ?? model.labName, labHref(model.lab))), + models.map(providerDetailCell), ), comparisonDetailRow( "Context length", @@ -899,7 +912,7 @@ function buildComparisonDetailSections(models: readonly ComparisonModel[]): Comp ), comparisonDetailRow( "Providers", - models.map((model) => linkedTextCell(model.labName, labHref(model.lab))), + models.map(providerDetailCell), ), ], }, @@ -1013,6 +1026,15 @@ function comparisonRef(model: ComparisonModel): ComparisonModelRef { } } +function comparisonModelLabel(model: ComparisonModel) { + return model.labName ? `${model.name} from ${model.labName}` : model.name +} + +function providerDetailCell(model: ComparisonModel): ComparisonDetailCell { + if (!model.labName) return textCell("") + return linkedTextCell(model.stats?.author ?? model.labName ?? "", labHref(model.lab)) +} + function textCell(value: string): ComparisonDetailCell { return { value } } diff --git a/packages/stats/app/src/routes/[lab]/[model].tsx b/packages/stats/app/src/routes/[lab]/[model].tsx index 977660a83c80..24cba8c08372 100644 --- a/packages/stats/app/src/routes/[lab]/[model].tsx +++ b/packages/stats/app/src/routes/[lab]/[model].tsx @@ -17,7 +17,13 @@ import { LocaleLinks } from "../../component/locale-links" import { useI18n } from "../../context/i18n" import { useLanguage } from "../../context/language" import { localizedUrl } from "../../lib/language" -import { findModelCatalogEntry, formatCatalogLabName, loadModelCatalog, type ModelCatalogEntry } from "../model-catalog" +import { + findModelCatalogEntry, + formatCatalogLabName, + isKnownCatalogLab, + loadModelCatalog, + type ModelCatalogEntry, +} from "../model-catalog" import { SectionHeading } from "../section-heading" import { runStatsEffect } from "../../stats-runtime" import { setStatsPageCacheHeaders } from "../stats-cache" @@ -96,7 +102,9 @@ export default function StatsModel() { const modelName = createMemo( () => catalogEntry()?.name ?? publicModelName(canonicalModel()) ?? i18n.t("model.fallback"), ) - const labName = createMemo(() => formatCatalogLabName(catalogEntry()?.lab ?? stats()?.provider ?? labParam())) + const lab = createMemo(() => catalogEntry()?.lab ?? stats()?.provider ?? labParam()) + const catalogLabs = createMemo(() => page()?.catalog.labs.map((item) => item.id) ?? []) + const labName = createMemo(() => (isKnownCatalogLab(lab(), catalogLabs()) ? formatCatalogLabName(lab()) : undefined)) const formerName = createMemo(() => formerModelName(canonicalModel())) const searchModelName = createMemo(() => (formerName() ? `${modelName()} (formerly ${formerName()})` : modelName())) const modelTitle = createMemo(() => i18n.t("model.title", { model: searchModelName() })) @@ -185,9 +193,14 @@ export default function StatsModel() { - + props.catalog?.lab ?? props.data?.provider ?? props.labName + const labId = () => props.catalog?.lab ?? props.data?.provider + const hasLab = () => props.labName !== undefined const modelName = () => props.catalog?.name ?? props.data?.model ?? i18n.t("model.fallback") const weights = () => props.catalog?.weights[0] const labs = () => props.catalogData?.labs ?? [] @@ -281,35 +295,31 @@ function ModelHero(props: { Data - / - 0} - fallback={ - - {props.labName} - - - } - > - ({ - href: language.route(`${import.meta.env.BASE_URL}${lab.id}`), - label: lab.name, - value: lab.id, - }))} - value={providerSlug(labId())} - variant="model" - /> + + / + 0} + fallback={{props.labName}} + > + ({ + href: language.route(`${import.meta.env.BASE_URL}${lab.id}`), + label: lab.name, + value: lab.id, + }))} + value={providerSlug(labId() ?? "")} + variant="model" + /> + / 0} fallback={ - - {modelName()} - + + {modelName()} } > @@ -328,9 +338,11 @@ function ModelHero(props: {
- - + + + +

{modelName()}

@@ -980,7 +992,7 @@ function GeoCountryList(props: { ) } -function ModelPeersSection(props: { data: StatsModelPageData | null }) { +function ModelPeersSection(props: { data: StatsModelPageData | null; catalogLabs: readonly string[] }) { const i18n = useI18n() return (
@@ -993,7 +1005,7 @@ function ModelPeersSection(props: { data: StatsModelPageData | null }) { >
    - {(peer) => } + {(peer) => }
@@ -1011,23 +1023,29 @@ function MetricCard(props: { label: string; value: string; detail?: string; stat ) } -function PeerRow(props: { peer: ModelPeerEntry; active: boolean }) { +function PeerRow(props: { peer: ModelPeerEntry; active: boolean; catalogLabs: readonly string[] }) { const language = useLanguage() + const hasProvider = () => isKnownCatalogLab(props.peer.provider, props.catalogLabs) return (
  • {String(props.peer.rank).padStart(2, "0")} - - + + + + {props.peer.model} - {props.peer.author} + + {props.peer.author} + {formatTokens(props.peer.tokens)} @@ -1050,6 +1068,7 @@ function ModelEmptyState(props: { title: string; description: string; compact?: function modelComparisonPairs( catalogModels: ModelCatalogOption[] | undefined, + catalogLabs: readonly string[], catalogEntry: ModelCatalogEntry | null, data: StatsModelPageData | null, ) { @@ -1064,7 +1083,7 @@ function modelComparisonPairs( name: peer.model, lab: peer.provider, slug: peer.slug, - labName: peer.author, + labName: isKnownCatalogLab(peer.provider, catalogLabs) ? peer.author : undefined, metric: `#${peer.rank} / ${formatTokens(peer.tokens)}`, }, detail: "Usage peer", @@ -1090,7 +1109,7 @@ function modelComparisonRef( name: data.model, lab: data.provider, slug: data.slug, - labName: data.author, + labName: undefined, metric: `#${data.rank}`, } } diff --git a/packages/stats/app/src/routes/compare-cards.tsx b/packages/stats/app/src/routes/compare-cards.tsx index 24077bc3b9c4..50a0a38002ae 100644 --- a/packages/stats/app/src/routes/compare-cards.tsx +++ b/packages/stats/app/src/routes/compare-cards.tsx @@ -119,17 +119,24 @@ function ComparisonCardIcon() { } function ComparisonPanelCard(props: { pair: ComparisonPair }) { + const firstLabName = () => props.pair.first.labName + const secondLabName = () => props.pair.second.labName + return ( {props.pair.detail} {props.pair.first.name} vs {props.pair.second.name} -

    - {props.pair.first.labName ?? formatCatalogLabName(props.pair.first.lab)} - - {props.pair.second.labName ?? formatCatalogLabName(props.pair.second.lab)} -

    + +

    + {(name) => {name()}} + + + + {(name) => {name()}} +

    +
    {props.pair.first.metric ?? "Listed"} / {props.pair.second.metric ?? "Listed"} @@ -143,14 +150,16 @@ function ComparisonLabLogo(props: { model: ComparisonModelRef }) { const iconId = () => providerIconId(props.model.lab) return ( - - + + + + ) } diff --git a/packages/stats/app/src/routes/compare-radar.tsx b/packages/stats/app/src/routes/compare-radar.tsx index d7403809ac87..35ada12885f1 100644 --- a/packages/stats/app/src/routes/compare-radar.tsx +++ b/packages/stats/app/src/routes/compare-radar.tsx @@ -9,7 +9,7 @@ const toolUseBenchmarkPattern = /(terminal bench|claw eval|tau ?(?:bench|2|3))/ export type ComparisonRadarModel = { name: string - labName: string + labName?: string catalog: ModelCatalogEntry | null } @@ -61,7 +61,7 @@ export function ComparisonRadar(props: ComparisonRadarProps) {