MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / fetchModelsForProvider

Function fetchModelsForProvider

out/cli.cjs:86348–86416  ·  view source on GitHub ↗
(provider, apiKey, baseUrl, forceRefresh = false)

Source from the content-addressed store, hash-verified

86346 }
86347 const data = await response.json();
86348 const models = data.data?.map((m5) => m5.id).sort();
86349 return models && models.length > 0 ? models : MODEL_LIST.deepseek;
86350 } catch {
86351 return MODEL_LIST.deepseek;
86352 }
86353}
86354async function fetchModelsForProvider(provider, apiKey, baseUrl, forceRefresh = false) {
86355 const cache = readCache();
86356 if (!forceRefresh && isCacheValid(cache) && cache.models[provider]) {
86357 return cache.models[provider];
86358 }
86359 let models = [];
86360 switch (provider.toLowerCase()) {
86361 case "openai" /* OPENAI */:
86362 if (apiKey) {
86363 models = await fetchOpenAIModels(apiKey);
86364 } else {
86365 models = MODEL_LIST.openai;
86366 }
86367 break;
86368 case "ollama" /* OLLAMA */:
86369 models = await fetchOllamaModels(baseUrl);
86370 break;
86371 case "llamacpp" /* LLAMACPP */:
86372 models = await fetchLlamaCppModels(baseUrl);
86373 break;
86374 case "anthropic" /* ANTHROPIC */:
86375 if (apiKey) {
86376 models = await fetchAnthropicModels(apiKey);
86377 } else {
86378 models = MODEL_LIST.anthropic;
86379 }
86380 break;
86381 case "gemini" /* GEMINI */:
86382 models = MODEL_LIST.gemini;
86383 break;
86384 case "groq" /* GROQ */:
86385 if (apiKey) {
86386 models = await fetchGroqModels(apiKey);
86387 } else {
86388 models = MODEL_LIST.groq;
86389 }
86390 break;
86391 case "mistral" /* MISTRAL */:
86392 if (apiKey) {
86393 models = await fetchMistralModels(apiKey);
86394 } else {
86395 models = MODEL_LIST.mistral;
86396 }
86397 break;
86398 case "deepseek" /* DEEPSEEK */:
86399 if (apiKey) {
86400 models = await fetchDeepSeekModels(apiKey);
86401 } else {
86402 models = MODEL_LIST.deepseek;
86403 }
86404 break;
86405 case "aimlapi" /* AIMLAPI */:

Callers 2

selectModelFunction · 0.70
refreshModelsFunction · 0.70

Calls 12

toLowerCaseMethod · 0.80
readCacheFunction · 0.70
isCacheValidFunction · 0.70
fetchOpenAIModelsFunction · 0.70
fetchOllamaModelsFunction · 0.70
fetchLlamaCppModelsFunction · 0.70
fetchAnthropicModelsFunction · 0.70
fetchGroqModelsFunction · 0.70
fetchMistralModelsFunction · 0.70
fetchDeepSeekModelsFunction · 0.70
fetchOpenRouterModelsFunction · 0.70
writeCacheFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…