(provider, apiKey, baseUrl, forceRefresh = false)
| 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 | } |
| 86354 | async 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 */: |
no test coverage detected
searching dependent graphs…