|
@@ -25,7 +25,9 @@
|
|
|
const getModels = async () => {
|
|
|
const models = await _getModels(
|
|
|
localStorage.token,
|
|
|
- $config?.features?.enable_direct_connections && ($settings?.directConnections ?? null)
|
|
|
+ $config?.features?.enable_direct_connections && ($settings?.directConnections ?? null),
|
|
|
+ false,
|
|
|
+ true
|
|
|
);
|
|
|
return models;
|
|
|
};
|
|
@@ -216,35 +218,102 @@
|
|
|
<form class="flex flex-col h-full justify-between text-sm" on:submit|preventDefault={submitHandler}>
|
|
|
<div class=" overflow-y-scroll scrollbar-hidden h-full">
|
|
|
{#if ENABLE_OPENAI_API !== null && ENABLE_OLLAMA_API !== null && directConnectionsConfig !== null}
|
|
|
- <div class="my-2">
|
|
|
- <div class="mt-2 space-y-2 pr-1.5">
|
|
|
- <div class="flex justify-between items-center text-sm">
|
|
|
- <div class=" font-medium">{$i18n.t('OpenAI API')}</div>
|
|
|
+ <div class="mb-3.5">
|
|
|
+ <div class=" mb-2.5 text-base font-medium">{$i18n.t('General')}</div>
|
|
|
|
|
|
- <div class="flex items-center">
|
|
|
- <div class="">
|
|
|
- <Switch
|
|
|
- bind:state={ENABLE_OPENAI_API}
|
|
|
- on:change={async () => {
|
|
|
- updateOpenAIHandler();
|
|
|
- }}
|
|
|
- />
|
|
|
+ <hr class=" border-gray-100 dark:border-gray-850 my-2" />
|
|
|
+
|
|
|
+ <div class="my-2">
|
|
|
+ <div class="mt-2 space-y-2">
|
|
|
+ <div class="flex justify-between items-center text-sm">
|
|
|
+ <div class=" font-medium">{$i18n.t('OpenAI API')}</div>
|
|
|
+
|
|
|
+ <div class="flex items-center">
|
|
|
+ <div class="">
|
|
|
+ <Switch
|
|
|
+ bind:state={ENABLE_OPENAI_API}
|
|
|
+ on:change={async () => {
|
|
|
+ updateOpenAIHandler();
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
+
|
|
|
+ {#if ENABLE_OPENAI_API}
|
|
|
+ <div class="">
|
|
|
+ <div class="flex justify-between items-center">
|
|
|
+ <div class="font-medium text-xs">{$i18n.t('Manage OpenAI API Connections')}</div>
|
|
|
+
|
|
|
+ <Tooltip content={$i18n.t(`Add Connection`)}>
|
|
|
+ <button
|
|
|
+ class="px-1"
|
|
|
+ on:click={() => {
|
|
|
+ showAddOpenAIConnectionModal = true;
|
|
|
+ }}
|
|
|
+ type="button"
|
|
|
+ >
|
|
|
+ <Plus />
|
|
|
+ </button>
|
|
|
+ </Tooltip>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="flex flex-col gap-1.5 mt-1.5">
|
|
|
+ {#each OPENAI_API_BASE_URLS as url, idx}
|
|
|
+ <OpenAIConnection
|
|
|
+ pipeline={pipelineUrls[url] ? true : false}
|
|
|
+ bind:url
|
|
|
+ bind:key={OPENAI_API_KEYS[idx]}
|
|
|
+ bind:config={OPENAI_API_CONFIGS[idx]}
|
|
|
+ onSubmit={() => {
|
|
|
+ updateOpenAIHandler();
|
|
|
+ }}
|
|
|
+ onDelete={() => {
|
|
|
+ OPENAI_API_BASE_URLS = OPENAI_API_BASE_URLS.filter(
|
|
|
+ (url, urlIdx) => idx !== urlIdx
|
|
|
+ );
|
|
|
+ OPENAI_API_KEYS = OPENAI_API_KEYS.filter((key, keyIdx) => idx !== keyIdx);
|
|
|
+
|
|
|
+ let newConfig = {};
|
|
|
+ OPENAI_API_BASE_URLS.forEach((url, newIdx) => {
|
|
|
+ newConfig[newIdx] =
|
|
|
+ OPENAI_API_CONFIGS[newIdx < idx ? newIdx : newIdx + 1];
|
|
|
+ });
|
|
|
+ OPENAI_API_CONFIGS = newConfig;
|
|
|
+ updateOpenAIHandler();
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ {/each}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ {/if}
|
|
|
</div>
|
|
|
+ </div>
|
|
|
|
|
|
- {#if ENABLE_OPENAI_API}
|
|
|
- <hr class=" border-gray-100 dark:border-gray-850" />
|
|
|
+ <div class=" my-2">
|
|
|
+ <div class="flex justify-between items-center text-sm mb-2">
|
|
|
+ <div class=" font-medium">{$i18n.t('Ollama API')}</div>
|
|
|
|
|
|
+ <div class="mt-1">
|
|
|
+ <Switch
|
|
|
+ bind:state={ENABLE_OLLAMA_API}
|
|
|
+ on:change={async () => {
|
|
|
+ updateOllamaHandler();
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ {#if ENABLE_OLLAMA_API}
|
|
|
<div class="">
|
|
|
<div class="flex justify-between items-center">
|
|
|
- <div class="font-medium">{$i18n.t('Manage OpenAI API Connections')}</div>
|
|
|
+ <div class="font-medium text-xs">{$i18n.t('Manage Ollama API Connections')}</div>
|
|
|
|
|
|
<Tooltip content={$i18n.t(`Add Connection`)}>
|
|
|
<button
|
|
|
class="px-1"
|
|
|
on:click={() => {
|
|
|
- showAddOpenAIConnectionModal = true;
|
|
|
+ showAddOllamaConnectionModal = true;
|
|
|
}}
|
|
|
type="button"
|
|
|
>
|
|
@@ -253,131 +322,62 @@
|
|
|
</Tooltip>
|
|
|
</div>
|
|
|
|
|
|
- <div class="flex flex-col gap-1.5 mt-1.5">
|
|
|
- {#each OPENAI_API_BASE_URLS as url, idx}
|
|
|
- <OpenAIConnection
|
|
|
- pipeline={pipelineUrls[url] ? true : false}
|
|
|
- bind:url
|
|
|
- bind:key={OPENAI_API_KEYS[idx]}
|
|
|
- bind:config={OPENAI_API_CONFIGS[idx]}
|
|
|
- onSubmit={() => {
|
|
|
- updateOpenAIHandler();
|
|
|
- }}
|
|
|
- onDelete={() => {
|
|
|
- OPENAI_API_BASE_URLS = OPENAI_API_BASE_URLS.filter(
|
|
|
- (url, urlIdx) => idx !== urlIdx
|
|
|
- );
|
|
|
- OPENAI_API_KEYS = OPENAI_API_KEYS.filter((key, keyIdx) => idx !== keyIdx);
|
|
|
-
|
|
|
- let newConfig = {};
|
|
|
- OPENAI_API_BASE_URLS.forEach((url, newIdx) => {
|
|
|
- newConfig[newIdx] = OPENAI_API_CONFIGS[newIdx < idx ? newIdx : newIdx + 1];
|
|
|
- });
|
|
|
- OPENAI_API_CONFIGS = newConfig;
|
|
|
- updateOpenAIHandler();
|
|
|
- }}
|
|
|
- />
|
|
|
- {/each}
|
|
|
+ <div class="flex w-full gap-1.5">
|
|
|
+ <div class="flex-1 flex flex-col gap-1.5 mt-1.5">
|
|
|
+ {#each OLLAMA_BASE_URLS as url, idx}
|
|
|
+ <OllamaConnection
|
|
|
+ bind:url
|
|
|
+ bind:config={OLLAMA_API_CONFIGS[idx]}
|
|
|
+ {idx}
|
|
|
+ onSubmit={() => {
|
|
|
+ updateOllamaHandler();
|
|
|
+ }}
|
|
|
+ onDelete={() => {
|
|
|
+ OLLAMA_BASE_URLS = OLLAMA_BASE_URLS.filter((url, urlIdx) => idx !== urlIdx);
|
|
|
+
|
|
|
+ let newConfig = {};
|
|
|
+ OLLAMA_BASE_URLS.forEach((url, newIdx) => {
|
|
|
+ newConfig[newIdx] =
|
|
|
+ OLLAMA_API_CONFIGS[newIdx < idx ? newIdx : newIdx + 1];
|
|
|
+ });
|
|
|
+ OLLAMA_API_CONFIGS = newConfig;
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ {/each}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="mt-1 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>
|
|
|
{/if}
|
|
|
</div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <hr class=" border-gray-100 dark:border-gray-850" />
|
|
|
-
|
|
|
- <div class="pr-1.5 my-2">
|
|
|
- <div class="flex justify-between items-center text-sm mb-2">
|
|
|
- <div class=" font-medium">{$i18n.t('Ollama API')}</div>
|
|
|
-
|
|
|
- <div class="mt-1">
|
|
|
- <Switch
|
|
|
- bind:state={ENABLE_OLLAMA_API}
|
|
|
- on:change={async () => {
|
|
|
- updateOllamaHandler();
|
|
|
- }}
|
|
|
- />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- {#if ENABLE_OLLAMA_API}
|
|
|
- <hr class=" border-gray-100 dark:border-gray-850 my-2" />
|
|
|
|
|
|
- <div class="">
|
|
|
- <div class="flex justify-between items-center">
|
|
|
- <div class="font-medium">{$i18n.t('Manage Ollama API Connections')}</div>
|
|
|
+ <div class="my-2">
|
|
|
+ <div class="flex justify-between items-center text-sm">
|
|
|
+ <div class=" font-medium">{$i18n.t('Direct Connections')}</div>
|
|
|
|
|
|
- <Tooltip content={$i18n.t(`Add Connection`)}>
|
|
|
- <button
|
|
|
- class="px-1"
|
|
|
- on:click={() => {
|
|
|
- showAddOllamaConnectionModal = true;
|
|
|
+ <div class="flex items-center">
|
|
|
+ <div class="">
|
|
|
+ <Switch
|
|
|
+ bind:state={directConnectionsConfig.ENABLE_DIRECT_CONNECTIONS}
|
|
|
+ on:change={async () => {
|
|
|
+ updateDirectConnectionsHandler();
|
|
|
}}
|
|
|
- type="button"
|
|
|
- >
|
|
|
- <Plus />
|
|
|
- </button>
|
|
|
- </Tooltip>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="flex w-full gap-1.5">
|
|
|
- <div class="flex-1 flex flex-col gap-1.5 mt-1.5">
|
|
|
- {#each OLLAMA_BASE_URLS as url, idx}
|
|
|
- <OllamaConnection
|
|
|
- bind:url
|
|
|
- bind:config={OLLAMA_API_CONFIGS[idx]}
|
|
|
- {idx}
|
|
|
- onSubmit={() => {
|
|
|
- updateOllamaHandler();
|
|
|
- }}
|
|
|
- onDelete={() => {
|
|
|
- OLLAMA_BASE_URLS = OLLAMA_BASE_URLS.filter((url, urlIdx) => idx !== urlIdx);
|
|
|
-
|
|
|
- let newConfig = {};
|
|
|
- OLLAMA_BASE_URLS.forEach((url, newIdx) => {
|
|
|
- newConfig[newIdx] = OLLAMA_API_CONFIGS[newIdx < idx ? newIdx : newIdx + 1];
|
|
|
- });
|
|
|
- OLLAMA_API_CONFIGS = newConfig;
|
|
|
- }}
|
|
|
- />
|
|
|
- {/each}
|
|
|
+ />
|
|
|
</div>
|
|
|
</div>
|
|
|
-
|
|
|
- <div class="mt-1 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>
|
|
|
- {/if}
|
|
|
- </div>
|
|
|
-
|
|
|
- <hr class=" border-gray-100 dark:border-gray-850" />
|
|
|
-
|
|
|
- <div class="pr-1.5 my-2">
|
|
|
- <div class="flex justify-between items-center text-sm">
|
|
|
- <div class=" font-medium">{$i18n.t('Direct Connections')}</div>
|
|
|
-
|
|
|
- <div class="flex items-center">
|
|
|
- <div class="">
|
|
|
- <Switch
|
|
|
- bind:state={directConnectionsConfig.ENABLE_DIRECT_CONNECTIONS}
|
|
|
- on:change={async () => {
|
|
|
- updateDirectConnectionsHandler();
|
|
|
- }}
|
|
|
- />
|
|
|
- </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
|
|
|
- <div class="mt-1.5">
|
|
|
- <div class="text-xs text-gray-500">
|
|
|
+ <div class="mt-1 text-xs text-gray-400 dark:text-gray-500">
|
|
|
{$i18n.t(
|
|
|
'Direct Connections allow users to connect to their own OpenAI compatible API endpoints.'
|
|
|
)}
|