mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-21 12:03:31 +00:00
fix(stats): merge renamed model data (#43812)
Co-authored-by: fwang <83515+fwang@users.noreply.github.com> Co-authored-by: Frank <frank@anoma.ly>
This commit is contained in:
parent
5e77c494c7
commit
876a4a2586
3 changed files with 22 additions and 1 deletions
|
|
@ -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([])
|
||||
|
||||
|
|
|
|||
|
|
@ -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')`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<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) {
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue