From 436e3ff7de122961b8817e79a0d3f28f3b8c91ac Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Wed, 2 Apr 2025 20:42:23 -0700 Subject: [PATCH] refac --- src/lib/components/AddServerModal.svelte | 15 ++++--- src/lib/components/chat/Settings/Tools.svelte | 4 +- .../chat/Settings/Tools/Connection.svelte | 45 ++++++++----------- 3 files changed, 30 insertions(+), 34 deletions(-) diff --git a/src/lib/components/AddServerModal.svelte b/src/lib/components/AddServerModal.svelte index ca07e8b88..d0f79c576 100644 --- a/src/lib/components/AddServerModal.svelte +++ b/src/lib/components/AddServerModal.svelte @@ -25,7 +25,7 @@ export let connection = null; let url = ''; - let openApiPath = '/openapi.json'; + let path = '/openapi.json'; let auth_type = 'bearer'; let key = ''; @@ -42,6 +42,8 @@ const connection = { url, + path, + auth_type, key, config: { enable: enable @@ -55,15 +57,18 @@ url = ''; key = ''; + path = '/openapi.json'; + auth_type = 'bearer'; + enable = true; }; const init = () => { if (connection) { 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 ?? ''; enable = connection.config?.enable ?? true; @@ -137,7 +142,7 @@ {$i18n.t(`WebUI will make requests to "{{url}}{{path}}"`, { url: url, - path: openApiPath + path: path })} diff --git a/src/lib/components/chat/Settings/Tools.svelte b/src/lib/components/chat/Settings/Tools.svelte index 7195fc699..bb207ce7f 100644 --- a/src/lib/components/chat/Settings/Tools.svelte +++ b/src/lib/components/chat/Settings/Tools.svelte @@ -74,9 +74,7 @@
{#each servers as server, idx} { updateHandler(); }} diff --git a/src/lib/components/chat/Settings/Tools/Connection.svelte b/src/lib/components/chat/Settings/Tools/Connection.svelte index 426b6a137..27dd1758c 100644 --- a/src/lib/components/chat/Settings/Tools/Connection.svelte +++ b/src/lib/components/chat/Settings/Tools/Connection.svelte @@ -11,11 +11,7 @@ export let onDelete = () => {}; export let onSubmit = () => {}; - export let pipeline = false; - - export let url = ''; - export let key = ''; - export let config = {}; + export let connection = null; let showConfigModal = false; let showDeleteConfirmDialog = false; @@ -25,19 +21,13 @@ edit direct bind:show={showConfigModal} - connection={{ - url, - key, - config - }} + {connection} onDelete={() => { showDeleteConfirmDialog = true; }} - onSubmit={(connection) => { - url = connection.url; - key = connection.key; - config = connection.config; - onSubmit(connection); + onSubmit={(c) => { + connection = c; + onSubmit(c); }} /> @@ -52,12 +42,13 @@
- {#if !(config?.enable ?? true)} + {#if !(connection?.config?.enable ?? true)}
@@ -65,19 +56,21 @@
- + {#if (connection?.auth_type ?? 'bearer') === 'bearer'} + + {/if}