mirror of
https://github.com/open-webui/open-webui
synced 2025-06-16 19:31:52 +00:00
refac
This commit is contained in:
parent
41442897e3
commit
2e24c2d4d3
@ -9,7 +9,8 @@
|
|||||||
getOllamaVersion,
|
getOllamaVersion,
|
||||||
pullModel,
|
pullModel,
|
||||||
cancelOllamaRequest,
|
cancelOllamaRequest,
|
||||||
uploadModel
|
uploadModel,
|
||||||
|
getOllamaConfig
|
||||||
} from '$lib/apis/ollama';
|
} from '$lib/apis/ollama';
|
||||||
|
|
||||||
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
|
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
|
||||||
@ -28,6 +29,8 @@
|
|||||||
|
|
||||||
// Models
|
// Models
|
||||||
|
|
||||||
|
let ollamaEnabled = null;
|
||||||
|
|
||||||
let OLLAMA_URLS = [];
|
let OLLAMA_URLS = [];
|
||||||
let selectedOllamaUrlIdx: string | null = null;
|
let selectedOllamaUrlIdx: string | null = null;
|
||||||
|
|
||||||
@ -431,6 +434,11 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
const ollamaConfig = await getOllamaConfig(localStorage.token);
|
||||||
|
|
||||||
|
if (ollamaConfig.ENABLE_OLLAMA_API) {
|
||||||
|
ollamaEnabled = true;
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
(async () => {
|
(async () => {
|
||||||
OLLAMA_URLS = await getOllamaUrls(localStorage.token).catch((error) => {
|
OLLAMA_URLS = await getOllamaUrls(localStorage.token).catch((error) => {
|
||||||
@ -446,11 +454,16 @@
|
|||||||
ollamaVersion = await getOllamaVersion(localStorage.token).catch((error) => false);
|
ollamaVersion = await getOllamaVersion(localStorage.token).catch((error) => false);
|
||||||
})()
|
})()
|
||||||
]);
|
]);
|
||||||
|
} else {
|
||||||
|
ollamaEnabled = false;
|
||||||
|
toast.error('Ollama API is disabled');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col h-full justify-between text-sm">
|
<div class="flex flex-col h-full justify-between text-sm">
|
||||||
<div class=" space-y-3 pr-1.5 overflow-y-scroll h-[24rem]">
|
<div class=" space-y-3 pr-1.5 overflow-y-scroll h-[24rem]">
|
||||||
|
{#if ollamaEnabled}
|
||||||
{#if ollamaVersion !== null}
|
{#if ollamaVersion !== null}
|
||||||
<div class="space-y-2 pr-1.5">
|
<div class="space-y-2 pr-1.5">
|
||||||
<div class="text-sm font-medium">{$i18n.t('Manage Ollama Models')}</div>
|
<div class="text-sm font-medium">{$i18n.t('Manage Ollama Models')}</div>
|
||||||
@ -725,7 +738,9 @@
|
|||||||
<div class="flex w-full mb-1.5">
|
<div class="flex w-full mb-1.5">
|
||||||
<div class="flex flex-col w-full">
|
<div class="flex flex-col w-full">
|
||||||
{#if modelUploadMode === 'file'}
|
{#if modelUploadMode === 'file'}
|
||||||
<div class="flex-1 {modelInputFile && modelInputFile.length > 0 ? 'mr-2' : ''}">
|
<div
|
||||||
|
class="flex-1 {modelInputFile && modelInputFile.length > 0 ? 'mr-2' : ''}"
|
||||||
|
>
|
||||||
<input
|
<input
|
||||||
id="model-upload-input"
|
id="model-upload-input"
|
||||||
bind:this={modelUploadInputElement}
|
bind:this={modelUploadInputElement}
|
||||||
@ -891,5 +906,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
{:else if ollamaEnabled === false}
|
||||||
|
<div>Ollama API is disabled</div>
|
||||||
|
{:else}
|
||||||
|
<div class="flex h-full justify-center">
|
||||||
|
<div class="my-auto">
|
||||||
|
<Spinner className="size-6" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user