Unverified Commit 8df0429c authored by Timothy Jaeryang Baek's avatar Timothy Jaeryang Baek Committed by GitHub
Browse files

Merge branch 'dev' into feat/model-config

parents f21c8626 59602eea
......@@ -3,7 +3,13 @@
import { createEventDispatcher, onMount, getContext } from 'svelte';
const dispatch = createEventDispatcher();
import { getOllamaUrls, getOllamaVersion, updateOllamaUrls } from '$lib/apis/ollama';
import {
getOllamaConfig,
getOllamaUrls,
getOllamaVersion,
updateOllamaConfig,
updateOllamaUrls
} from '$lib/apis/ollama';
import {
getOpenAIConfig,
getOpenAIKeys,
......@@ -26,6 +32,7 @@
let OPENAI_API_BASE_URLS = [''];
let ENABLE_OPENAI_API = false;
let ENABLE_OLLAMA_API = false;
const updateOpenAIHandler = async () => {
OPENAI_API_BASE_URLS = await updateOpenAIUrls(localStorage.token, OPENAI_API_BASE_URLS);
......@@ -50,10 +57,13 @@
onMount(async () => {
if ($user.role === 'admin') {
OLLAMA_BASE_URLS = await getOllamaUrls(localStorage.token);
const ollamaConfig = await getOllamaConfig(localStorage.token);
const openaiConfig = await getOpenAIConfig(localStorage.token);
const config = await getOpenAIConfig(localStorage.token);
ENABLE_OPENAI_API = config.ENABLE_OPENAI_API;
ENABLE_OPENAI_API = openaiConfig.ENABLE_OPENAI_API;
ENABLE_OLLAMA_API = ollamaConfig.ENABLE_OLLAMA_API;
OLLAMA_BASE_URLS = await getOllamaUrls(localStorage.token);
OPENAI_API_BASE_URLS = await getOpenAIUrls(localStorage.token);
OPENAI_API_KEYS = await getOpenAIKeys(localStorage.token);
......@@ -161,95 +171,108 @@
<hr class=" dark:border-gray-700" />
<div>
<div class=" mb-2.5 text-sm font-medium">{$i18n.t('Ollama Base URL')}</div>
<div class="flex w-full gap-1.5">
<div class="flex-1 flex flex-col gap-2">
{#each OLLAMA_BASE_URLS as url, idx}
<div class="flex gap-1.5">
<input
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
placeholder={$i18n.t('Enter URL (e.g. http://localhost:11434)')}
bind:value={url}
/>
<div class="pr-1.5 space-y-2">
<div class="flex justify-between items-center text-sm">
<div class=" font-medium">{$i18n.t('Ollama API')}</div>
<div class="mt-1">
<Switch
bind:state={ENABLE_OLLAMA_API}
on:change={async () => {
updateOllamaConfig(localStorage.token, ENABLE_OLLAMA_API);
}}
/>
</div>
</div>
{#if ENABLE_OLLAMA_API}
<div class="flex w-full gap-1.5">
<div class="flex-1 flex flex-col gap-2">
{#each OLLAMA_BASE_URLS as url, idx}
<div class="flex gap-1.5">
<input
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
placeholder={$i18n.t('Enter URL (e.g. http://localhost:11434)')}
bind:value={url}
/>
<div class="self-center flex items-center">
{#if idx === 0}
<button
class="px-1"
on:click={() => {
OLLAMA_BASE_URLS = [...OLLAMA_BASE_URLS, ''];
}}
type="button"
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"
fill="currentColor"
class="w-4 h-4"
<div class="self-center flex items-center">
{#if idx === 0}
<button
class="px-1"
on:click={() => {
OLLAMA_BASE_URLS = [...OLLAMA_BASE_URLS, ''];
}}
type="button"
>
<path
d="M8.75 3.75a.75.75 0 0 0-1.5 0v3.5h-3.5a.75.75 0 0 0 0 1.5h3.5v3.5a.75.75 0 0 0 1.5 0v-3.5h3.5a.75.75 0 0 0 0-1.5h-3.5v-3.5Z"
/>
</svg>
</button>
{:else}
<button
class="px-1"
on:click={() => {
OLLAMA_BASE_URLS = OLLAMA_BASE_URLS.filter((url, urlIdx) => idx !== urlIdx);
}}
type="button"
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"
fill="currentColor"
class="w-4 h-4"
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"
fill="currentColor"
class="w-4 h-4"
>
<path
d="M8.75 3.75a.75.75 0 0 0-1.5 0v3.5h-3.5a.75.75 0 0 0 0 1.5h3.5v3.5a.75.75 0 0 0 1.5 0v-3.5h3.5a.75.75 0 0 0 0-1.5h-3.5v-3.5Z"
/>
</svg>
</button>
{:else}
<button
class="px-1"
on:click={() => {
OLLAMA_BASE_URLS = OLLAMA_BASE_URLS.filter((url, urlIdx) => idx !== urlIdx);
}}
type="button"
>
<path d="M3.75 7.25a.75.75 0 0 0 0 1.5h8.5a.75.75 0 0 0 0-1.5h-8.5Z" />
</svg>
</button>
{/if}
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"
fill="currentColor"
class="w-4 h-4"
>
<path d="M3.75 7.25a.75.75 0 0 0 0 1.5h8.5a.75.75 0 0 0 0-1.5h-8.5Z" />
</svg>
</button>
{/if}
</div>
</div>
</div>
{/each}
</div>
{/each}
</div>
<div class="">
<button
class="p-2.5 bg-gray-200 hover:bg-gray-300 dark:bg-gray-850 dark:hover:bg-gray-800 rounded-lg transition"
on:click={() => {
updateOllamaUrlsHandler();
}}
type="button"
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
class="w-4 h-4"
<div class="flex">
<button
class="self-center p-2 bg-gray-200 hover:bg-gray-300 dark:bg-gray-900 dark:hover:bg-gray-850 rounded-lg transition"
on:click={() => {
updateOllamaUrlsHandler();
}}
type="button"
>
<path
fill-rule="evenodd"
d="M15.312 11.424a5.5 5.5 0 01-9.201 2.466l-.312-.311h2.433a.75.75 0 000-1.5H3.989a.75.75 0 00-.75.75v4.242a.75.75 0 001.5 0v-2.43l.31.31a7 7 0 0011.712-3.138.75.75 0 00-1.449-.39zm1.23-3.723a.75.75 0 00.219-.53V2.929a.75.75 0 00-1.5 0V5.36l-.31-.31A7 7 0 003.239 8.188a.75.75 0 101.448.389A5.5 5.5 0 0113.89 6.11l.311.31h-2.432a.75.75 0 000 1.5h4.243a.75.75 0 00.53-.219z"
clip-rule="evenodd"
/>
</svg>
</button>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
class="w-4 h-4"
>
<path
fill-rule="evenodd"
d="M15.312 11.424a5.5 5.5 0 01-9.201 2.466l-.312-.311h2.433a.75.75 0 000-1.5H3.989a.75.75 0 00-.75.75v4.242a.75.75 0 001.5 0v-2.43l.31.31a7 7 0 0011.712-3.138.75.75 0 00-1.449-.39zm1.23-3.723a.75.75 0 00.219-.53V2.929a.75.75 0 00-1.5 0V5.36l-.31-.31A7 7 0 003.239 8.188a.75.75 0 101.448.389A5.5 5.5 0 0113.89 6.11l.311.31h-2.432a.75.75 0 000 1.5h4.243a.75.75 0 00.53-.219z"
clip-rule="evenodd"
/>
</svg>
</button>
</div>
</div>
</div>
<div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
{$i18n.t('Trouble accessing Ollama?')}
<a
class=" text-gray-300 font-medium underline"
href="https://github.com/open-webui/open-webui#troubleshooting"
target="_blank"
>
{$i18n.t('Click here for help.')}
</a>
</div>
<div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
{$i18n.t('Trouble accessing Ollama?')}
<a
class=" text-gray-300 font-medium underline"
href="https://github.com/open-webui/open-webui#troubleshooting"
target="_blank"
>
{$i18n.t('Click here for help.')}
</a>
</div>
{/if}
</div>
</div>
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "حسنا دعنا نذهب!",
"OLED Dark": "OLED داكن",
"Ollama": "Ollama",
"Ollama Base URL": "Ollama الرابط الافتراضي",
"Ollama API": "",
"Ollama Version": "Ollama الاصدار",
"On": "تشغيل",
"Only": "فقط",
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "ОК, Нека започваме!",
"OLED Dark": "OLED тъмно",
"Ollama": "Ollama",
"Ollama Base URL": "Ollama Базов URL",
"Ollama API": "",
"Ollama Version": "Ollama Версия",
"On": "Вкл.",
"Only": "Само",
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "ঠিক আছে, চলুন যাই!",
"OLED Dark": "OLED ডার্ক",
"Ollama": "Ollama",
"Ollama Base URL": "Ollama বেজ ইউআরএল",
"Ollama API": "",
"Ollama Version": "Ollama ভার্সন",
"On": "চালু",
"Only": "শুধুমাত্র",
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "D'acord, Anem!",
"OLED Dark": "OLED Fosc",
"Ollama": "Ollama",
"Ollama Base URL": "URL Base d'Ollama",
"Ollama API": "",
"Ollama Version": "Versió d'Ollama",
"On": "Activat",
"Only": "Només",
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "Okay, los geht's!",
"OLED Dark": "OLED Dunkel",
"Ollama": "Ollama",
"Ollama Base URL": "Ollama Basis URL",
"Ollama API": "",
"Ollama Version": "Ollama-Version",
"On": "Ein",
"Only": "Nur",
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "Okay, Let's Go!",
"OLED Dark": "OLED Dark",
"Ollama": "",
"Ollama Base URL": "Ollama Base Bark",
"Ollama API": "",
"Ollama Version": "Ollama Version",
"On": "On",
"Only": "Only",
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "",
"OLED Dark": "",
"Ollama": "",
"Ollama Base URL": "",
"Ollama API": "",
"Ollama Version": "",
"On": "",
"Only": "",
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "",
"OLED Dark": "",
"Ollama": "",
"Ollama Base URL": "",
"Ollama API": "",
"Ollama Version": "",
"On": "",
"Only": "",
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "Bien, ¡Vamos!",
"OLED Dark": "OLED oscuro",
"Ollama": "Ollama",
"Ollama Base URL": "URL base de Ollama",
"Ollama API": "",
"Ollama Version": "Versión de Ollama",
"On": "Activado",
"Only": "Solamente",
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "باشه، بزن بریم!",
"OLED Dark": "OLED تیره",
"Ollama": "Ollama",
"Ollama Base URL": "URL پایه اولاما",
"Ollama API": "",
"Ollama Version": "نسخه اولاما",
"On": "روشن",
"Only": "فقط",
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "Eikun menoksi!",
"OLED Dark": "OLED-tumma",
"Ollama": "Ollama",
"Ollama Base URL": "Ollama-perus-URL",
"Ollama API": "",
"Ollama Version": "Ollama-versio",
"On": "Päällä",
"Only": "Vain",
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "Okay, Allons-y !",
"OLED Dark": "OLED Sombre",
"Ollama": "Ollama",
"Ollama Base URL": "URL de Base Ollama",
"Ollama API": "",
"Ollama Version": "Version Ollama",
"On": "Activé",
"Only": "Seulement",
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "D'accord, allons-y !",
"OLED Dark": "OLED Sombre",
"Ollama": "Ollama",
"Ollama Base URL": "URL de Base Ollama",
"Ollama API": "",
"Ollama Version": "Version Ollama",
"On": "Activé",
"Only": "Seulement",
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "בסדר, בואו נתחיל!",
"OLED Dark": "OLED כהה",
"Ollama": "Ollama",
"Ollama Base URL": "כתובת URL בסיסית של Ollama",
"Ollama API": "",
"Ollama Version": "גרסת Ollama",
"On": "פועל",
"Only": "רק",
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "ठीक है, चलिए चलते हैं!",
"OLED Dark": "OLEDescuro",
"Ollama": "Ollama",
"Ollama Base URL": "Ollama URL",
"Ollama API": "",
"Ollama Version": "Ollama Version",
"On": "चालू",
"Only": "केवल",
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "U redu, idemo!",
"OLED Dark": "OLED Tamno",
"Ollama": "Ollama",
"Ollama Base URL": "Osnovni URL Ollama",
"Ollama API": "",
"Ollama Version": "Verzija Ollama",
"On": "Uključeno",
"Only": "Samo",
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "Ok, andiamo!",
"OLED Dark": "OLED scuro",
"Ollama": "Ollama",
"Ollama Base URL": "URL base Ollama",
"Ollama API": "",
"Ollama Version": "Versione Ollama",
"On": "Attivato",
"Only": "Solo",
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "OK、始めましょう!",
"OLED Dark": "OLED ダーク",
"Ollama": "Ollama",
"Ollama Base URL": "Ollama ベース URL",
"Ollama API": "",
"Ollama Version": "Ollama バージョン",
"On": "オン",
"Only": "のみ",
......
......@@ -314,7 +314,7 @@
"Okay, Let's Go!": "კარგი, წავედით!",
"OLED Dark": "OLED მუქი",
"Ollama": "Ollama",
"Ollama Base URL": "Ollama ბაზისური მისამართი",
"Ollama API": "",
"Ollama Version": "Ollama ვერსია",
"On": "ჩართვა",
"Only": "მხოლოდ",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment