fix(stats): map lab aliases

This commit is contained in:
Adam 2026-06-17 05:37:59 -05:00
commit 85a79292e6
No known key found for this signature in database
GPG key ID: 9CB48779AF150E75
2 changed files with 29 additions and 6 deletions

View file

@ -823,15 +823,14 @@ function resolveModelProvider(model: string, rows: StatMetricRow[], providerPara
}
function providerMatches(provider: string, providerParam: string) {
return modelSlug(provider) === modelSlug(providerParam)
return providerSlug(provider) === providerSlug(providerParam)
}
function resolveProviderName(providerParam: string, rows: StatMetricRow[]) {
const input = providerParam.trim()
if (!input) return undefined
const inputSlug = modelSlug(input)
return aggregateByModel(rows)
.filter((item) => modelSlug(item.provider) === inputSlug)
.filter((item) => providerMatches(item.provider, input))
.toSorted((a, b) => b.totalTokens - a.totalTokens || a.provider.localeCompare(b.provider))[0]?.provider
}
@ -848,6 +847,17 @@ function modelKey(provider: string, model: string) {
return `${provider}\u0000${model}`
}
function providerSlug(value: string) {
const slug = modelSlug(value)
const aliases: Record<string, string> = {
alibaba: "qwen",
moonshotai: "moonshot",
qwen: "qwen",
zhipuai: "zhipu",
}
return aliases[slug] ?? slug
}
function costPerMillion(costMicrocents: number, tokens: number) {
if (tokens <= 0 || costMicrocents <= 0) return 0
return round((microcentsToDollars(costMicrocents) / tokens) * TOKEN_SCALE, 2)