MCPcopy Index your code
hub / github.com/simstudioai/sim / getProviderFromModel

Function getProviderFromModel

apps/sim/providers/utils.ts:263–298  ·  view source on GitHub ↗
(model: string)

Source from the content-addressed store, hash-verified

261}
262
263export function getProviderFromModel(model: string): ProviderId {
264 const normalizedModel = model.toLowerCase()
265
266 let providerId: ProviderId | null = null
267
268 if (normalizedModel in getAllModelProviders()) {
269 providerId = getAllModelProviders()[normalizedModel]
270 } else {
271 for (const [id, config] of Object.entries(providers)) {
272 if (config.modelPatterns) {
273 for (const pattern of config.modelPatterns) {
274 if (pattern.test(normalizedModel)) {
275 providerId = id as ProviderId
276 break
277 }
278 }
279 }
280 if (providerId) break
281 }
282 }
283
284 if (!providerId) {
285 logger.warn(`No provider found for model: ${model}, defaulting to ollama`)
286 providerId = 'ollama'
287 }
288
289 if (isProviderBlacklisted(providerId)) {
290 throw new Error(`Provider "${providerId}" is not available`)
291 }
292
293 if (isModelBlacklisted(normalizedModel)) {
294 throw new Error(`Model "${model}" is not available`)
295 }
296
297 return providerId
298}
299
300export function getProvider(id: string): ProviderMetadata | undefined {
301 const providerId = id.split('/')[0] as ProviderId

Callers 15

chat.tsFile · 0.90
utils.test.tsFile · 0.90
getPiModelOptionsFunction · 0.90
combobox.tsxFile · 0.90
tool-input.tsxFile · 0.90
FileUploadFunction · 0.90
useSubBlockValueFunction · 0.90
executeMethod · 0.90
executeLegacyMethod · 0.90
executeV2Method · 0.90

Calls 5

getAllModelProvidersFunction · 0.85
isProviderBlacklistedFunction · 0.85
isModelBlacklistedFunction · 0.85
testMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected