mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-22 03:43:24 +00:00
fix(stats): merge renamed model data (#43883)
This commit is contained in:
parent
8ecd4c21bf
commit
0af9dd61d2
3 changed files with 22 additions and 1 deletions
|
|
@ -41,6 +41,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([])
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import {
|
|||
EXCLUDED_MODELS,
|
||||
FREE_MODELS,
|
||||
MODEL_AUTHOR_RULES,
|
||||
MODEL_NAME_ALIASES,
|
||||
RETIRED_STAT_PROVIDERS,
|
||||
statModel,
|
||||
statProvider,
|
||||
|
|
@ -302,6 +303,9 @@ function statPeriods(grain: "day" | "week", periodStart: Date, periodEnd: Date)
|
|||
function statModelSql(model: string, providerModel: string) {
|
||||
return `COALESCE(NULLIF(regexp_replace(CASE
|
||||
WHEN lower(${model}) = 'big-pickle' THEN regexp_replace(NULLIF(${providerModel}, ''), '^.*/', '')
|
||||
${Object.entries(MODEL_NAME_ALIASES)
|
||||
.map(([from, to]) => ` WHEN lower(${model}) = ${sqlString(from)} THEN ${sqlString(to)}`)
|
||||
.join("\n")}
|
||||
ELSE ${model}
|
||||
END, '(-free|:free|:global)+$', ''), ''), 'unknown')`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,11 @@ export const MODEL_AUTHOR_RULES = [
|
|||
] as const
|
||||
export const EXCLUDED_MODELS = new Set(["alpha-gpt-next"])
|
||||
export const FREE_MODELS = new Set(["gpt-5-nano", "grok-code", "big-pickle"])
|
||||
export const RETIRED_STAT_MODELS = ["big-pickle"]
|
||||
export const MODEL_NAME_ALIASES: Record<string, string> = {
|
||||
"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) {
|
||||
|
|
@ -31,6 +35,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?.split("/").at(-1))
|
||||
return normalized
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue