MCPcopy Create free account
hub / github.com/simstudioai/sim / getRelatedModels

Function getRelatedModels

apps/sim/app/(landing)/models/utils.ts:621–656  ·  view source on GitHub ↗
(targetModel: CatalogModel, limit = 6)

Source from the content-addressed store, hash-verified

619}
620
621export function getRelatedModels(targetModel: CatalogModel, limit = 6): CatalogModel[] {
622 const provider = MODEL_PROVIDERS_WITH_CATALOGS.find(
623 (entry) => entry.id === targetModel.providerId
624 )
625 if (!provider) {
626 return []
627 }
628
629 const targetTokens = new Set(tokenizeModelName(stripTechnicalSuffixes(targetModel.shortId)))
630
631 const scored = provider.models.reduce<Array<{ model: CatalogModel; score: number }>>(
632 (acc, model) => {
633 if (model.id === targetModel.id) {
634 return acc
635 }
636
637 const modelTokens = tokenizeModelName(stripTechnicalSuffixes(model.shortId))
638 const sharedTokenCount = modelTokens.filter((token) => targetTokens.has(token)).length
639 const sharedCapabilityCount = model.capabilityTags.filter((tag) =>
640 targetModel.capabilityTags.includes(tag)
641 ).length
642
643 acc.push({
644 model,
645 score: sharedTokenCount * 2 + sharedCapabilityCount + (model.contextWindow ?? 0) / 1000000,
646 })
647 return acc
648 },
649 []
650 )
651
652 return scored
653 .sort((a, b) => b.score - a.score)
654 .slice(0, limit)
655 .map(({ model }) => model)
656}
657
658export function buildProviderFaqs(provider: CatalogProvider): CatalogFaq[] {
659 const cheapestModel = getCheapestProviderModel(provider)

Callers 1

ModelPageFunction · 0.90

Calls 3

tokenizeModelNameFunction · 0.85
stripTechnicalSuffixesFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected