fix(stats): map lab aliases
This commit is contained in:
parent
5c9e4ff21b
commit
85a79292e6
2 changed files with 29 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue