diff --git a/packages/stats/core/src/domain/inference.test.ts b/packages/stats/core/src/domain/inference.test.ts index fa71fb51e60..967b0f553b8 100644 --- a/packages/stats/core/src/domain/inference.test.ts +++ b/packages/stats/core/src/domain/inference.test.ts @@ -38,6 +38,17 @@ describe("inference stat normalization", () => { expect(statProvider("unknown", "", "custom-provider")).toBe("custom-provider") }) + test("merges renamed models under their current name", () => { + expect(statModel("x-preview-f", "")).toBe("ox-alpha") + expect(statModel("xiaomi/mimo-v2.5", "")).toBe("mimo-v2.5") + expect(toModelAggregate(aggregate("x-preview-f", "openai"))).toMatchObject([ + { + provider: "openai", + model: "ox-alpha", + }, + ]) + }) + test("model aggregates prefer provider.model and use normalized model", () => { expect(toModelAggregate(aggregate("alpha-gpt-next", "openai"))).toEqual([]) diff --git a/packages/stats/core/src/domain/inference.ts b/packages/stats/core/src/domain/inference.ts index 558832f9953..6c23283c535 100644 --- a/packages/stats/core/src/domain/inference.ts +++ b/packages/stats/core/src/domain/inference.ts @@ -5,6 +5,7 @@ import type { ModelStatAggregate } from "./model" import { EXCLUDED_MODELS, MODEL_AUTHOR_RULES, + MODEL_NAME_ALIASES, RETIRED_STAT_PROVIDERS, statModel, statProvider, @@ -253,6 +254,9 @@ function sqlString(value: string) { function statModelSql(model: string, providerModel: string) { return `COALESCE(NULLIF(regexp_replace(CASE WHEN lower(${model}) = 'big-pickle' THEN NULLIF(${providerModel}, '') +${Object.entries(MODEL_NAME_ALIASES) + .map(([from, to]) => ` WHEN lower(${model}) = ${sqlString(from)} THEN ${sqlString(to)}`) + .join("\n")} ELSE ${model} END, '(-free|:global)+$', ''), ''), 'unknown')` } diff --git a/packages/stats/core/src/domain/model-normalization.ts b/packages/stats/core/src/domain/model-normalization.ts index 6d273afe5d2..248a48a239a 100644 --- a/packages/stats/core/src/domain/model-normalization.ts +++ b/packages/stats/core/src/domain/model-normalization.ts @@ -13,7 +13,11 @@ export const MODEL_AUTHOR_RULES = [ { match: "qwen", author: "qwen" }, ] as const export const EXCLUDED_MODELS = new Set(["alpha-gpt-next"]) -export const RETIRED_STAT_MODELS = ["big-pickle"] +export const MODEL_NAME_ALIASES: Record = { + "x-preview-f": "ox-alpha", + "xiaomi/mimo-v2.5": "mimo-v2.5", +} +export const RETIRED_STAT_MODELS = ["big-pickle", ...Object.keys(MODEL_NAME_ALIASES)] export const RETIRED_STAT_PROVIDERS = ["opencode"] export function normalizeInferenceModel(value: string | undefined) { @@ -29,6 +33,8 @@ export function modelAuthor(value: string | undefined) { export function statModel(model: string | undefined, providerModel: string | undefined) { const normalized = normalizeInferenceModel(model) + const alias = MODEL_NAME_ALIASES[normalized.toLowerCase()] + if (alias) return alias if (RETIRED_STAT_MODELS.includes(normalized.toLowerCase())) return normalizeInferenceModel(providerModel) return normalized }