fix: tool server api key not being sent

This commit is contained in:
Timothy Jaeryang Baek 2025-04-02 19:52:12 -07:00
parent 959995c715
commit 2277566ce1
2 changed files with 52 additions and 14 deletions

View File

@ -25,7 +25,11 @@
export let connection = null;
let url = '';
let openApiPath = '/openapi.json';
let auth_type = 'bearer';
let key = '';
let enable = true;
let loading = false;
@ -57,7 +61,10 @@
const init = () => {
if (connection) {
url = connection.url;
key = connection.key;
openApiPath = connection.openApiPath ?? '/openapi.json';
auth_type = connection.auth_type ?? 'bearer';
key = connection?.key ?? '';
enable = connection.config?.enable ?? true;
}
@ -125,9 +132,20 @@
required
/>
</div>
<div class="flex-1">
<input
class="w-full text-sm bg-transparent placeholder:text-gray-300 dark:placeholder:text-gray-700 outline-hidden"
type="text"
bind:value={openApiPath}
placeholder={$i18n.t('openapi.json Path')}
autocomplete="off"
required
/>
</div>
</div>
<div class="flex flex-col shrink-0 self-end">
<div class="flex flex-col shrink-0 self-start">
<Tooltip content={enable ? $i18n.t('Enabled') : $i18n.t('Disabled')}>
<Switch bind:state={enable} />
</Tooltip>
@ -135,22 +153,41 @@
</div>
<div class="text-xs text-gray-500 mt-1">
{$i18n.t(`WebUI will make requests to "{{url}}/openapi.json"`, {
url: url
{$i18n.t(`WebUI will make requests to "{{url}}{{path}}"`, {
url: url,
path: openApiPath
})}
</div>
<div class="flex gap-2 mt-2">
<div class="flex flex-col w-full">
<div class=" mb-0.5 text-xs text-gray-500">{$i18n.t('Key')}</div>
<div class=" text-xs text-gray-500">{$i18n.t('Auth')}</div>
<div class="flex-1">
<SensitiveInput
className="w-full text-sm bg-transparent placeholder:text-gray-300 dark:placeholder:text-gray-700 outline-hidden"
bind:value={key}
placeholder={$i18n.t('API Key')}
required={false}
/>
<div class="flex gap-2">
<div class="flex-shrink-0 self-start">
<select
class="w-full text-sm bg-transparent placeholder:text-gray-300 dark:placeholder:text-gray-700 outline-hidden pr-5"
bind:value={auth_type}
>
<option value="bearer">Bearer</option>
<option value="session">Session</option>
</select>
</div>
<div class="flex flex-1 items-center">
{#if auth_type === 'bearer'}
<SensitiveInput
className="w-full text-sm bg-transparent placeholder:text-gray-300 dark:placeholder:text-gray-700 outline-hidden"
bind:value={key}
placeholder={$i18n.t('API Key')}
required={false}
/>
{:else if auth_type === 'session'}
<div class="text-xs text-gray-500 self-center translate-y-[1px]">
{$i18n.t('Forwards system user session credentials to authenticate')}
</div>
{/if}
</div>
</div>
</div>
</div>

View File

@ -205,7 +205,8 @@
};
const executeTool = async (data, cb) => {
const toolServer = $toolServers?.find((server) => server.url === data.server?.url);
const toolServer = $settings?.toolServers?.find((server) => server.url === data.server?.url);
const toolServerData = $toolServers?.find((server) => server.url === data.server?.url);
console.log('executeTool', data, toolServer);
@ -215,7 +216,7 @@
toolServer.url,
data?.name,
data?.params,
toolServer
toolServerData
);
console.log('executeToolServer', res);