refac: external tools server support

This commit is contained in:
Timothy Jaeryang Baek
2025-03-27 02:27:56 -07:00
parent 69dee19568
commit d1bc2cfa2f
9 changed files with 264 additions and 30 deletions

View File

@@ -35,7 +35,8 @@
showOverview,
chatTitle,
showArtifacts,
tools
tools,
toolServers
} from '$lib/stores';
import {
convertMessagesToHistory,
@@ -120,8 +121,6 @@
let webSearchEnabled = false;
let codeInterpreterEnabled = false;
let toolServers = [];
let chat = null;
let tags = [];
@@ -194,8 +193,6 @@
setToolIds();
}
$: toolServers = ($settings?.toolServers ?? []).filter((server) => server?.config?.enable);
const setToolIds = async () => {
if (!$tools) {
tools.set(await getTools(localStorage.token));
@@ -1570,6 +1567,7 @@
files: (files?.length ?? 0) > 0 ? files : undefined,
tool_ids: selectedToolIds.length > 0 ? selectedToolIds : undefined,
tool_servers: $toolServers,
features: {
image_generation:
@@ -2038,7 +2036,7 @@
bind:codeInterpreterEnabled
bind:webSearchEnabled
bind:atSelectedModel
{toolServers}
toolServers={$toolServers}
transparentBackground={$settings?.backgroundImageUrl ?? false}
{stopResponse}
{createMessagePair}
@@ -2092,7 +2090,7 @@
bind:webSearchEnabled
bind:atSelectedModel
transparentBackground={$settings?.backgroundImageUrl ?? false}
{toolServers}
toolServers={$toolServers}
{stopResponse}
{createMessagePair}
on:upload={async (e) => {

View File

@@ -1,12 +1,12 @@
<script lang="ts">
import { toast } from 'svelte-sonner';
import { createEventDispatcher, onMount, getContext, tick } from 'svelte';
import { getModels as _getModels } from '$lib/apis';
import { getModels as _getModels, getToolServersData } from '$lib/apis';
const dispatch = createEventDispatcher();
const i18n = getContext('i18n');
import { models, settings, user } from '$lib/stores';
import { models, settings, toolServers, user } from '$lib/stores';
import Switch from '$lib/components/common/Switch.svelte';
import Spinner from '$lib/components/common/Spinner.svelte';
@@ -30,6 +30,8 @@
await saveSettings({
toolServers: servers
});
toolServers.set(await getToolServersData($settings?.toolServers ?? []));
};
onMount(async () => {