|
@@ -13,6 +13,7 @@
|
|
import {
|
|
import {
|
|
getOpenAIConfig,
|
|
getOpenAIConfig,
|
|
getOpenAIKeys,
|
|
getOpenAIKeys,
|
|
|
|
+ getOpenAIModels,
|
|
getOpenAIUrls,
|
|
getOpenAIUrls,
|
|
updateOpenAIConfig,
|
|
updateOpenAIConfig,
|
|
updateOpenAIKeys,
|
|
updateOpenAIKeys,
|
|
@@ -21,6 +22,7 @@
|
|
import { toast } from 'svelte-sonner';
|
|
import { toast } from 'svelte-sonner';
|
|
import Switch from '$lib/components/common/Switch.svelte';
|
|
import Switch from '$lib/components/common/Switch.svelte';
|
|
import Spinner from '$lib/components/common/Spinner.svelte';
|
|
import Spinner from '$lib/components/common/Spinner.svelte';
|
|
|
|
+ import Tooltip from '$lib/components/common/Tooltip.svelte';
|
|
|
|
|
|
const i18n = getContext('i18n');
|
|
const i18n = getContext('i18n');
|
|
|
|
|
|
@@ -35,6 +37,34 @@
|
|
let ENABLE_OPENAI_API = null;
|
|
let ENABLE_OPENAI_API = null;
|
|
let ENABLE_OLLAMA_API = null;
|
|
let ENABLE_OLLAMA_API = null;
|
|
|
|
|
|
|
|
+ const verifyOpenAIHandler = async (idx) => {
|
|
|
|
+ OPENAI_API_BASE_URLS = await updateOpenAIUrls(localStorage.token, OPENAI_API_BASE_URLS);
|
|
|
|
+ OPENAI_API_KEYS = await updateOpenAIKeys(localStorage.token, OPENAI_API_KEYS);
|
|
|
|
+
|
|
|
|
+ const res = await getOpenAIModels(localStorage.token, idx).catch((error) => {
|
|
|
|
+ toast.error(error);
|
|
|
|
+ return null;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if (res) {
|
|
|
|
+ toast.success($i18n.t('Server connection verified'));
|
|
|
|
+ console.log(res);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const verifyOllamaHandler = async (idx) => {
|
|
|
|
+ OLLAMA_BASE_URLS = await updateOllamaUrls(localStorage.token, OLLAMA_BASE_URLS);
|
|
|
|
+
|
|
|
|
+ const res = await getOllamaVersion(localStorage.token, idx).catch((error) => {
|
|
|
|
+ toast.error(error);
|
|
|
|
+ return null;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if (res) {
|
|
|
|
+ toast.success($i18n.t('Server connection verified'));
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
const updateOpenAIHandler = async () => {
|
|
const updateOpenAIHandler = async () => {
|
|
OPENAI_API_BASE_URLS = await updateOpenAIUrls(localStorage.token, OPENAI_API_BASE_URLS);
|
|
OPENAI_API_BASE_URLS = await updateOpenAIUrls(localStorage.token, OPENAI_API_BASE_URLS);
|
|
OPENAI_API_KEYS = await updateOpenAIKeys(localStorage.token, OPENAI_API_KEYS);
|
|
OPENAI_API_KEYS = await updateOpenAIKeys(localStorage.token, OPENAI_API_KEYS);
|
|
@@ -83,6 +113,8 @@
|
|
class="flex flex-col h-full justify-between text-sm"
|
|
class="flex flex-col h-full justify-between text-sm"
|
|
on:submit|preventDefault={() => {
|
|
on:submit|preventDefault={() => {
|
|
updateOpenAIHandler();
|
|
updateOpenAIHandler();
|
|
|
|
+ updateOllamaUrlsHandler();
|
|
|
|
+
|
|
dispatch('save');
|
|
dispatch('save');
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
@@ -167,6 +199,31 @@
|
|
</button>
|
|
</button>
|
|
{/if}
|
|
{/if}
|
|
</div>
|
|
</div>
|
|
|
|
+
|
|
|
|
+ <div class="flex">
|
|
|
|
+ <Tooltip content="Verify connection" className="self-start mt-0.5">
|
|
|
|
+ <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={() => {
|
|
|
|
+ verifyOpenAIHandler(idx);
|
|
|
|
+ }}
|
|
|
|
+ type="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>
|
|
|
|
+ </Tooltip>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
<div class=" mb-1 text-xs text-gray-400 dark:text-gray-500">
|
|
<div class=" mb-1 text-xs text-gray-400 dark:text-gray-500">
|
|
{$i18n.t('WebUI will make requests to')}
|
|
{$i18n.t('WebUI will make requests to')}
|
|
@@ -245,32 +302,34 @@
|
|
</button>
|
|
</button>
|
|
{/if}
|
|
{/if}
|
|
</div>
|
|
</div>
|
|
|
|
+
|
|
|
|
+ <div class="flex">
|
|
|
|
+ <Tooltip content="Verify connection" className="self-start mt-0.5">
|
|
|
|
+ <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={() => {
|
|
|
|
+ verifyOllamaHandler(idx);
|
|
|
|
+ }}
|
|
|
|
+ type="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>
|
|
|
|
+ </Tooltip>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
{/each}
|
|
{/each}
|
|
</div>
|
|
</div>
|
|
-
|
|
|
|
- <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"
|
|
|
|
- >
|
|
|
|
- <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">
|
|
<div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
|