refac
Some checks are pending
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Python CI / Format Backend (3.11) (push) Waiting to run
Frontend Build / Format & Build Frontend (push) Waiting to run
Frontend Build / Frontend Unit Tests (push) Waiting to run

This commit is contained in:
Timothy Jaeryang Baek 2025-04-02 20:42:23 -07:00
parent c0711ba0c9
commit 436e3ff7de
3 changed files with 30 additions and 34 deletions

View File

@ -25,7 +25,7 @@
export let connection = null; export let connection = null;
let url = ''; let url = '';
let openApiPath = '/openapi.json'; let path = '/openapi.json';
let auth_type = 'bearer'; let auth_type = 'bearer';
let key = ''; let key = '';
@ -42,6 +42,8 @@
const connection = { const connection = {
url, url,
path,
auth_type,
key, key,
config: { config: {
enable: enable enable: enable
@ -55,15 +57,18 @@
url = ''; url = '';
key = ''; key = '';
path = '/openapi.json';
auth_type = 'bearer';
enable = true; enable = true;
}; };
const init = () => { const init = () => {
if (connection) { if (connection) {
url = connection.url; url = connection.url;
openApiPath = connection.openApiPath ?? '/openapi.json'; path = connection?.path ?? '/openapi.json';
auth_type = connection.auth_type ?? 'bearer'; auth_type = connection?.auth_type ?? 'bearer';
key = connection?.key ?? ''; key = connection?.key ?? '';
enable = connection.config?.enable ?? true; enable = connection.config?.enable ?? true;
@ -137,7 +142,7 @@
<input <input
class="w-full text-sm bg-transparent placeholder:text-gray-300 dark:placeholder:text-gray-700 outline-hidden" class="w-full text-sm bg-transparent placeholder:text-gray-300 dark:placeholder:text-gray-700 outline-hidden"
type="text" type="text"
bind:value={openApiPath} bind:value={path}
placeholder={$i18n.t('openapi.json Path')} placeholder={$i18n.t('openapi.json Path')}
autocomplete="off" autocomplete="off"
required required
@ -155,7 +160,7 @@
<div class="text-xs text-gray-500 mt-1"> <div class="text-xs text-gray-500 mt-1">
{$i18n.t(`WebUI will make requests to "{{url}}{{path}}"`, { {$i18n.t(`WebUI will make requests to "{{url}}{{path}}"`, {
url: url, url: url,
path: openApiPath path: path
})} })}
</div> </div>

View File

@ -74,9 +74,7 @@
<div class="flex flex-col gap-1.5"> <div class="flex flex-col gap-1.5">
{#each servers as server, idx} {#each servers as server, idx}
<Connection <Connection
bind:url={server.url} bind:connection={server}
bind:key={server.key}
bind:config={server.config}
onSubmit={() => { onSubmit={() => {
updateHandler(); updateHandler();
}} }}

View File

@ -11,11 +11,7 @@
export let onDelete = () => {}; export let onDelete = () => {};
export let onSubmit = () => {}; export let onSubmit = () => {};
export let pipeline = false; export let connection = null;
export let url = '';
export let key = '';
export let config = {};
let showConfigModal = false; let showConfigModal = false;
let showDeleteConfirmDialog = false; let showDeleteConfirmDialog = false;
@ -25,19 +21,13 @@
edit edit
direct direct
bind:show={showConfigModal} bind:show={showConfigModal}
connection={{ {connection}
url,
key,
config
}}
onDelete={() => { onDelete={() => {
showDeleteConfirmDialog = true; showDeleteConfirmDialog = true;
}} }}
onSubmit={(connection) => { onSubmit={(c) => {
url = connection.url; connection = c;
key = connection.key; onSubmit(c);
config = connection.config;
onSubmit(connection);
}} }}
/> />
@ -52,12 +42,13 @@
<div class="flex w-full gap-2 items-center"> <div class="flex w-full gap-2 items-center">
<Tooltip <Tooltip
className="w-full relative" className="w-full relative"
content={$i18n.t(`WebUI will make requests to "{{url}}/openapi.json"`, { content={$i18n.t(`WebUI will make requests to "{{url}}{{path}}"`, {
url: url url: connection?.url,
path: connection?.path ?? '/openapi.json'
})} })}
placement="top-start" placement="top-start"
> >
{#if !(config?.enable ?? true)} {#if !(connection?.config?.enable ?? true)}
<div <div
class="absolute top-0 bottom-0 left-0 right-0 opacity-60 bg-white dark:bg-gray-900 z-10" class="absolute top-0 bottom-0 left-0 right-0 opacity-60 bg-white dark:bg-gray-900 z-10"
></div> ></div>
@ -65,19 +56,21 @@
<div class="flex w-full"> <div class="flex w-full">
<div class="flex-1 relative"> <div class="flex-1 relative">
<input <input
class=" outline-hidden w-full bg-transparent {pipeline ? 'pr-8' : ''}" class=" outline-hidden w-full bg-transparent"
placeholder={$i18n.t('API Base URL')} placeholder={$i18n.t('API Base URL')}
bind:value={url} bind:value={connection.url}
autocomplete="off" autocomplete="off"
/> />
</div> </div>
<SensitiveInput {#if (connection?.auth_type ?? 'bearer') === 'bearer'}
inputClassName=" outline-hidden bg-transparent w-full" <SensitiveInput
placeholder={$i18n.t('API Key')} inputClassName=" outline-hidden bg-transparent w-full"
bind:value={key} placeholder={$i18n.t('API Key')}
required={false} bind:value={connection.key}
/> required={false}
/>
{/if}
</div> </div>
</Tooltip> </Tooltip>