mirror of
https://github.com/open-webui/open-webui
synced 2025-02-18 02:57:02 +00:00
refac
This commit is contained in:
parent
41442897e3
commit
2e24c2d4d3
@ -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,6 +434,11 @@
|
||||
};
|
||||
|
||||
onMount(async () => {
|
||||
const ollamaConfig = await getOllamaConfig(localStorage.token);
|
||||
|
||||
if (ollamaConfig.ENABLE_OLLAMA_API) {
|
||||
ollamaEnabled = true;
|
||||
|
||||
await Promise.all([
|
||||
(async () => {
|
||||
OLLAMA_URLS = await getOllamaUrls(localStorage.token).catch((error) => {
|
||||
@ -446,11 +454,16 @@
|
||||
ollamaVersion = await getOllamaVersion(localStorage.token).catch((error) => false);
|
||||
})()
|
||||
]);
|
||||
} else {
|
||||
ollamaEnabled = false;
|
||||
toast.error('Ollama API is disabled');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col h-full justify-between text-sm">
|
||||
<div class=" space-y-3 pr-1.5 overflow-y-scroll h-[24rem]">
|
||||
{#if ollamaEnabled}
|
||||
{#if ollamaVersion !== null}
|
||||
<div class="space-y-2 pr-1.5">
|
||||
<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 flex-col w-full">
|
||||
{#if modelUploadMode === 'file'}
|
||||
<div class="flex-1 {modelInputFile && modelInputFile.length > 0 ? 'mr-2' : ''}">
|
||||
<div
|
||||
class="flex-1 {modelInputFile && modelInputFile.length > 0 ? 'mr-2' : ''}"
|
||||
>
|
||||
<input
|
||||
id="model-upload-input"
|
||||
bind:this={modelUploadInputElement}
|
||||
@ -891,5 +906,14 @@
|
||||
</div>
|
||||
</div>
|
||||
{/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>
|
||||
|
Loading…
Reference in New Issue
Block a user