diff --git a/src/lib/components/chat/Settings/Models.svelte b/src/lib/components/chat/Settings/Models.svelte index 7254f2d27..c378f3f27 100644 --- a/src/lib/components/chat/Settings/Models.svelte +++ b/src/lib/components/chat/Settings/Models.svelte @@ -9,7 +9,8 @@ getOllamaVersion, pullModel, cancelOllamaRequest, - uploadModel + uploadModel, + getOllamaConfig } from '$lib/apis/ollama'; import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants'; @@ -28,6 +29,8 @@ // Models + let ollamaEnabled = null; + let OLLAMA_URLS = []; let selectedOllamaUrlIdx: string | null = null; @@ -431,381 +434,63 @@ }; onMount(async () => { - await Promise.all([ - (async () => { - OLLAMA_URLS = await getOllamaUrls(localStorage.token).catch((error) => { - toast.error(error); - return []; - }); + const ollamaConfig = await getOllamaConfig(localStorage.token); - if (OLLAMA_URLS.length > 0) { - selectedOllamaUrlIdx = 0; - } - })(), - (async () => { - ollamaVersion = await getOllamaVersion(localStorage.token).catch((error) => false); - })() - ]); + if (ollamaConfig.ENABLE_OLLAMA_API) { + ollamaEnabled = true; + + await Promise.all([ + (async () => { + OLLAMA_URLS = await getOllamaUrls(localStorage.token).catch((error) => { + toast.error(error); + return []; + }); + + if (OLLAMA_URLS.length > 0) { + selectedOllamaUrlIdx = 0; + } + })(), + (async () => { + ollamaVersion = await getOllamaVersion(localStorage.token).catch((error) => false); + })() + ]); + } else { + ollamaEnabled = false; + toast.error('Ollama API is disabled'); + } });