Skip to content

Commit 193de13

Browse files
committed
fix(stats): normalize deepseek v4.1 flash
1 parent 43e89ea commit 193de13

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

‎packages/stats/core/src/domain/inference.test.ts‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ import {
77
toProviderAggregate,
88
toRetentionAggregate,
99
} from "./inference"
10-
import { modelAuthor, normalizeInferenceModel, statModel, statProvider } from "./model-normalization"
10+
import {
11+
modelAuthor,
12+
normalizeInferenceModel,
13+
RETIRED_STAT_MODELS,
14+
statModel,
15+
statProvider,
16+
} from "./model-normalization"
1117

1218
describe("inference stat normalization", () => {
1319
test("normalizes model suffixes used by router/provider variants", () => {
@@ -86,6 +92,26 @@ describe("inference stat normalization", () => {
8692
expect(toProviderAggregate(aggregate("ox-alpha", "unknown"))).toMatchObject([{ provider: "zhipu" }])
8793
})
8894

95+
test("renames DeepSeek Flash to V4.1 without merging V4 or vision usage", () => {
96+
;["deepseek-flash", "DEEPSEEK-FLASH-free:global", "deepseek-v4.1-flash"].forEach((model) => {
97+
expect(statModel(model, "")).toBe("deepseek-v4.1-flash")
98+
expect(toModelAggregate(aggregate(model, "deepseek"))).toMatchObject([
99+
{ model: "deepseek-v4.1-flash", provider: "deepseek" },
100+
])
101+
expect(toGeoAggregate({ ...aggregate(model, "deepseek"), country: "US" })).toMatchObject([
102+
{ model: "deepseek-v4.1-flash", provider: "deepseek", country: "US" },
103+
])
104+
expect(toRetentionAggregate({ ...aggregate(model, "deepseek"), cohort_date: "2026-08-10" })).toMatchObject([
105+
{ model: "deepseek-v4.1-flash", provider: "deepseek" },
106+
])
107+
})
108+
expect(statModel("big-pickle", "deepseek/deepseek-flash")).toBe("deepseek-v4.1-flash")
109+
expect(statModel("deepseek-v4-flash", "")).toBe("deepseek-v4-flash")
110+
expect(statModel("deepseek-v4-flash-vision-exp", "")).toBe("deepseek-v4-flash-vision-exp")
111+
expect(RETIRED_STAT_MODELS).toContain("deepseek-flash")
112+
expect(RETIRED_STAT_MODELS).not.toContain("deepseek-v4.1-flash")
113+
})
114+
89115
test("model aggregates prefer provider.model and use normalized model", () => {
90116
expect(toModelAggregate(aggregate("alpha-gpt-next", "openai"))).toEqual([])
91117

@@ -145,6 +171,7 @@ describe("inference stat normalization", () => {
145171
queries.forEach((query) => {
146172
expect(query).toContain("WHERE lower(model) NOT IN ('alpha-gpt-next')")
147173
expect(query).toContain("CASE\n WHEN lower(model) IN ('omen-alpha') THEN 'unknown'\n")
174+
expect(query).toContain("= 'deepseek-flash' THEN 'deepseek-v4.1-flash'")
148175
})
149176
expect(queries[0]).toContain("'week' AS grain")
150177
expect(queries[0]).toContain("'2026-W33' AS period_key")
@@ -206,6 +233,9 @@ describe("inference stat normalization", () => {
206233
})
207234

208235
expect(queries).toHaveLength(2)
236+
queries.forEach(({ query }) => {
237+
expect(query).toContain("= 'deepseek-flash' THEN 'deepseek-v4.1-flash'")
238+
})
209239
expect(queries.map((query) => query.cohortDates)).toEqual([["2026-08-10"], ["2026-08-17"]])
210240
expect(queries[0]?.query).toContain("AND product = 'go'")
211241
expect(queries[0]?.query).toContain("AND lower(model) NOT IN ('alpha-gpt-next')")

‎packages/stats/core/src/domain/model-normalization.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const EXCLUDED_MODELS = new Set(["alpha-gpt-next"])
1717
export const STEALTH_MODELS = new Set(["omen-alpha"])
1818
export const FREE_MODELS = new Set(["gpt-5-nano", "grok-code", "big-pickle"])
1919
export const MODEL_NAME_ALIASES: Record<string, string> = {
20+
"deepseek-flash": "deepseek-v4.1-flash",
2021
"deepseek-v4-flash-0731": "deepseek-v4-flash",
2122
"deepseek-v4-flash-dsv4-flash-final-rnaovd": "deepseek-v4-flash",
2223
"ox-alpha": "glm-5.3-flash",

0 commit comments

Comments
 (0)