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'); + } });
- {#if ollamaVersion !== null} -
-
{$i18n.t('Manage Ollama Models')}
+ {#if ollamaEnabled} + {#if ollamaVersion !== null} +
+
{$i18n.t('Manage Ollama Models')}
- {#if OLLAMA_URLS.length > 0} -
-
- -
- -
-
- - - -
-
-
- - {#if updateModelId} - Updating "{updateModelId}" {updateProgress ? `(${updateProgress}%)` : ''} - {/if} - {/if} - -
-
-
{$i18n.t('Pull a model from Ollama.com')}
-
-
- -
- -
- -
- {$i18n.t('To access the available model names for downloading,')} - {$i18n.t('click here.')} -
- - {#if Object.keys($MODEL_DOWNLOAD_POOL).length > 0} - {#each Object.keys($MODEL_DOWNLOAD_POOL) as model} - {#if 'pullProgress' in $MODEL_DOWNLOAD_POOL[model]} -
-
{model}
-
-
-
-
- {$MODEL_DOWNLOAD_POOL[model].pullProgress ?? 0}% -
-
- - - - -
- {#if 'digest' in $MODEL_DOWNLOAD_POOL[model]} -
- {$MODEL_DOWNLOAD_POOL[model].digest} -
- {/if} -
-
- {/if} - {/each} - {/if} -
- -
-
{$i18n.t('Delete a model')}
-
-
+ {#if OLLAMA_URLS.length > 0} +
+
- -
-
-
-
-
{$i18n.t('Experimental')}
- -
-
- - {#if showExperimentalOllama} -
{ - uploadModelHandler(); - }} - > -
-
{$i18n.t('Upload a GGUF model')}
- - -
- -
-
- {#if modelUploadMode === 'file'} -
- { - console.log(modelInputFile); - }} - accept=".gguf,.safetensors" - required - hidden - /> - - -
- {:else} -
- -
- {/if} -
- - {#if (modelUploadMode === 'file' && modelInputFile && modelInputFile.length > 0) || (modelUploadMode === 'url' && modelFileUrl !== '')} - - {/if} + + +
+
+
+ + {#if updateModelId} + Updating "{updateModelId}" {updateProgress ? `(${updateProgress}%)` : ''} + {/if} + {/if} + +
+
+
{$i18n.t('Pull a model from Ollama.com')}
+
+
+ +
+
- {#if (modelUploadMode === 'file' && modelInputFile && modelInputFile.length > 0) || (modelUploadMode === 'url' && modelFileUrl !== '')} -
-
-
{$i18n.t('Modelfile Content')}
-