feat: add better provider support, icons, regen, and a lot more

This commit is contained in:
Zoe
2026-02-12 14:56:13 +00:00
parent d5a5945c03
commit d29f95bacf
124 changed files with 6374 additions and 1861 deletions
+42
View File
@@ -0,0 +1,42 @@
import type { Model } from "~/types/model";
export const filterProvidersWithModel = (providers: ProviderWithModels[], query: string): ProviderWithModels[] => {
const rawQuery = query.trim().toLowerCase();
if (!rawQuery) return providers;
return providers
.map((provider) => {
const scoredModels = filterModels(provider.models as Model[], query);
return { ...provider, models: scoredModels };
})
}
export const filterModels = (models: Model[], query: string): Model[] => {
const rawQuery = query.trim().toLowerCase();
if (!rawQuery) return models;
// Split search into individual words (tokens)
const tokens = rawQuery.split(/\s+/);
return models.map(model => {
const name = model.name.toLowerCase();
const id = model.externalId.toLowerCase();
// Check if all tokens match
const matches = tokens.every(t => name.includes(t) || id.includes(t));
if (!matches) return null;
// Calculate simple relevance score
let score = 0;
if (name.startsWith(rawQuery) || id.startsWith(rawQuery)) score += 10;
if (name === rawQuery || id === rawQuery) score += 50;
return { model, score };
})
.filter(m => m !== null)
.sort((a, b) => b.score - a.score)
.map(m => m.model);
}