MCPcopy
hub / github.com/anomalyco/models.dev / buildSearchItems

Function buildSearchItems

packages/web/src/render.tsx:298–394  ·  view source on GitHub ↗
(
  models: ModelEntry[],
  providers: Array<[string, CatalogProvider]>,
  labs: LabEntry[],
)

Source from the content-addressed store, hash-verified

296}
297
298function buildSearchItems(
299 models: ModelEntry[],
300 providers: Array<[string, CatalogProvider]>,
301 labs: LabEntry[],
302): SearchIndexItem[] {
303 const items: SearchIndexItem[] = [];
304
305 for (const model of models) {
306 const metadata = model.metadata;
307 items.push({
308 type: "model",
309 title: metadata.name,
310 id: model.id,
311 href: modelHref(model.id),
312 logo: labLogoHref(model.labId),
313 lab: model.labName,
314 providerCount: model.providers.length,
315 context: metadata.limit?.context,
316 releaseDate: metadata.release_date,
317 inputCost: model.minInputCost,
318 outputCost: model.minOutputCost,
319 description: metadata.description,
320 updated: metadata.last_updated,
321 tokens: [
322 metadata.name,
323 metadata.description,
324 model.id,
325 model.labName,
326 model.labId,
327 metadata.family,
328 metadata.release_date,
329 metadata.last_updated,
330 ...model.providers.flatMap((provider) => [
331 displayModelName(provider),
332 provider.modelId,
333 provider.provider.name,
334 provider.providerId,
335 ]),
336 ...(metadata.modalities?.input ?? []),
337 ...(metadata.modalities?.output ?? []),
338 ].filter((token): token is string => Boolean(token)),
339 });
340 }
341
342 for (const [providerId, provider] of providers) {
343 const providerModels = ProviderModelEntries.filter(
344 (entry) => entry.providerId === providerId,
345 );
346 const providerLastReleased = maxModelDate(providerModels, "release_date");
347 const providerLastUpdated = maxModelDate(providerModels, "last_updated");
348
349 items.push({
350 type: "provider",
351 title: provider.name,
352 id: providerId,
353 href: providerHref(providerId),
354 logo: logoHref(providerId),
355 modelCount: providerModels.length,

Callers 1

render.tsxFile · 0.85

Calls 7

modelHrefFunction · 0.85
labLogoHrefFunction · 0.85
displayModelNameFunction · 0.85
maxModelDateFunction · 0.85
providerHrefFunction · 0.85
logoHrefFunction · 0.85
labHrefFunction · 0.85

Tested by

no test coverage detected