fix(stats): normalize deepseek v4.1 flash

This commit is contained in:
Adam
2026-09-10 15:33:35 -05:00
parent 43e89ea167
commit 193de13a88
2 changed files with 32 additions and 1 deletions
@@ -7,7 +7,13 @@ import {
toProviderAggregate,
toRetentionAggregate,
} from "./inference"
import { modelAuthor, normalizeInferenceModel, statModel, statProvider } from "./model-normalization"
import {
modelAuthor,
normalizeInferenceModel,
RETIRED_STAT_MODELS,
statModel,
statProvider,
} from "./model-normalization"
describe("inference stat normalization", () => {
test("normalizes model suffixes used by router/provider variants", () => {
@@ -86,6 +92,26 @@ describe("inference stat normalization", () => {
expect(toProviderAggregate(aggregate("ox-alpha", "unknown"))).toMatchObject([{ provider: "zhipu" }])
})
test("renames DeepSeek Flash to V4.1 without merging V4 or vision usage", () => {
;["deepseek-flash", "DEEPSEEK-FLASH-free:global", "deepseek-v4.1-flash"].forEach((model) => {
expect(statModel(model, "")).toBe("deepseek-v4.1-flash")
expect(toModelAggregate(aggregate(model, "deepseek"))).toMatchObject([
{ model: "deepseek-v4.1-flash", provider: "deepseek" },
])
expect(toGeoAggregate({ ...aggregate(model, "deepseek"), country: "US" })).toMatchObject([
{ model: "deepseek-v4.1-flash", provider: "deepseek", country: "US" },
])
expect(toRetentionAggregate({ ...aggregate(model, "deepseek"), cohort_date: "2026-08-10" })).toMatchObject([
{ model: "deepseek-v4.1-flash", provider: "deepseek" },
])
})
expect(statModel("big-pickle", "deepseek/deepseek-flash")).toBe("deepseek-v4.1-flash")
expect(statModel("deepseek-v4-flash", "")).toBe("deepseek-v4-flash")
expect(statModel("deepseek-v4-flash-vision-exp", "")).toBe("deepseek-v4-flash-vision-exp")
expect(RETIRED_STAT_MODELS).toContain("deepseek-flash")
expect(RETIRED_STAT_MODELS).not.toContain("deepseek-v4.1-flash")
})
test("model aggregates prefer provider.model and use normalized model", () => {
expect(toModelAggregate(aggregate("alpha-gpt-next", "openai"))).toEqual([])
@@ -145,6 +171,7 @@ describe("inference stat normalization", () => {
queries.forEach((query) => {
expect(query).toContain("WHERE lower(model) NOT IN ('alpha-gpt-next')")
expect(query).toContain("CASE\n WHEN lower(model) IN ('omen-alpha') THEN 'unknown'\n")
expect(query).toContain("= 'deepseek-flash' THEN 'deepseek-v4.1-flash'")
})
expect(queries[0]).toContain("'week' AS grain")
expect(queries[0]).toContain("'2026-W33' AS period_key")
@@ -206,6 +233,9 @@ describe("inference stat normalization", () => {
})
expect(queries).toHaveLength(2)
queries.forEach(({ query }) => {
expect(query).toContain("= 'deepseek-flash' THEN 'deepseek-v4.1-flash'")
})
expect(queries.map((query) => query.cohortDates)).toEqual([["2026-08-10"], ["2026-08-17"]])
expect(queries[0]?.query).toContain("AND product = 'go'")
expect(queries[0]?.query).toContain("AND lower(model) NOT IN ('alpha-gpt-next')")
@@ -17,6 +17,7 @@ export const EXCLUDED_MODELS = new Set(["alpha-gpt-next"])
export const STEALTH_MODELS = new Set(["omen-alpha"])
export const FREE_MODELS = new Set(["gpt-5-nano", "grok-code", "big-pickle"])
export const MODEL_NAME_ALIASES: Record<string, string> = {
"deepseek-flash": "deepseek-v4.1-flash",
"deepseek-v4-flash-0731": "deepseek-v4-flash",
"deepseek-v4-flash-dsv4-flash-final-rnaovd": "deepseek-v4-flash",
"ox-alpha": "glm-5.3-flash",