1
0
Timothy Jaeryang Baek 1 сар өмнө
parent
commit
436e3ff7de

+ 10 - 5
src/lib/components/AddServerModal.svelte

@@ -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>
 
 

+ 1 - 3
src/lib/components/chat/Settings/Tools.svelte

@@ -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:key={server.key}
-									bind:config={server.config}
+									bind:connection={server}
 									onSubmit={() => {
 									onSubmit={() => {
 										updateHandler();
 										updateHandler();
 									}}
 									}}

+ 19 - 26
src/lib/components/chat/Settings/Tools/Connection.svelte

@@ -11,11 +11,7 @@
 	export let onDelete = () => {};
 	export let onDelete = () => {};
 	export let onSubmit = () => {};
 	export let onSubmit = () => {};
 
 
-	export let pipeline = false;
-
-	export let url = '';
-	export let key = '';
-	export let config = {};
+	export let connection = null;
 
 
 	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={{
-		url,
-		key,
-		config
-	}}
+	{connection}
 	onDelete={() => {
 	onDelete={() => {
 		showDeleteConfirmDialog = true;
 		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 @@
 <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"`, {
-			url: url
+		content={$i18n.t(`WebUI will make requests to "{{url}}{{path}}"`, {
+			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
-				inputClassName=" outline-hidden bg-transparent w-full"
-				placeholder={$i18n.t('API Key')}
-				bind:value={key}
-				required={false}
-			/>
+			{#if (connection?.auth_type ?? 'bearer') === 'bearer'}
+				<SensitiveInput
+					inputClassName=" outline-hidden bg-transparent w-full"
+					placeholder={$i18n.t('API Key')}
+					bind:value={connection.key}
+					required={false}
+				/>
+			{/if}
 		</div>
 		</div>
 	</Tooltip>
 	</Tooltip>