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

@ -63,17 +63,17 @@ export const getModelCatalog = query(async () => {
}, "getModelCatalog")
export function findModelCatalogEntry(catalog: ModelCatalog, model: string, lab?: string) {
const normalizedId = lab ? `${catalogSlug(lab)}/${catalogSlug(model)}` : model.trim().toLowerCase()
const normalizedId = lab ? `${catalogLabSlug(lab)}/${catalogSlug(model)}` : model.trim().toLowerCase()
const leaf = catalogSlug(model)
return (
catalog.models.find((entry) => entry.id.toLowerCase() === normalizedId) ??
catalog.models.find((entry) => (lab ? entry.lab === catalogSlug(lab) : true) && entry.slug === leaf) ??
catalog.models.find((entry) => (lab ? entry.lab === catalogLabSlug(lab) : true) && entry.slug === leaf) ??
catalog.models.find((entry) => entry.slug === leaf)
)
}
export function findModelCatalogLab(catalog: ModelCatalog, lab: string) {
const id = catalogSlug(lab)
const id = catalogLabSlug(lab)
return catalog.labs.find((entry) => entry.id === id)
}
@ -95,6 +95,8 @@ export function formatCatalogLabName(lab: string) {
xai: "xAI",
xiaomi: "Xiaomi",
zai: "Z.ai",
qwen: "Qwen",
zhipu: "Zhipu",
zhipuai: "Zhipu",
}
return known[catalogSlug(lab)] ?? lab.replace(/[-_]/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase())
@ -273,6 +275,17 @@ function catalogIdKey(value: string) {
return value.split("/").map(catalogSlug).join("/")
}
function catalogLabSlug(value: string) {
const slug = catalogSlug(value)
const aliases: Record<string, string> = {
moonshot: "moonshotai",
qwen: "alibaba",
zhipu: "zhipuai",
zai: "zhipuai",
}
return aliases[slug] ?? slug
}
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value)
}