mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-19 16:15:29 +00:00
fix(pricing): guard malformed models.dev model entries (#1344)
* fix(pricing): guard malformed models.dev model entries * style: apply prettier formatting
This commit is contained in:
1 parent
af7aa0c2dd
commit
66966f3527
2 files changed
+22
No files matched your search
@@ -91,6 +91,7 @@ function findModel(provider: ModelsDevProvider, model: string): ModelsDevModel |
|
||||
|
||||
const normalizedEntries = new Map<string, ModelsDevModel>();
|
||||
for (const [key, value] of Object.entries(models)) {
|
||||
if (!value || typeof value !== 'object') continue;
|
||||
normalizedEntries.set(normalizeId(key), value);
|
||||
if (typeof value.id === 'string') normalizedEntries.set(normalizeId(value.id), value);
|
||||
}
|
||||
@@ -188,6 +189,7 @@ export function getKnownModelsDevModels(): string[] {
|
||||
const ids = new Set<string>();
|
||||
for (const provider of Object.values(registry)) {
|
||||
for (const model of Object.values(provider.models ?? {})) {
|
||||
if (!model || typeof model !== 'object') continue;
|
||||
if (typeof model.id === 'string') ids.add(`${provider.id}/${model.id}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user