diff --git a/backend/open_webui/routers/configs.py b/backend/open_webui/routers/configs.py index e891b7aa8..44b2ef40c 100644 --- a/backend/open_webui/routers/configs.py +++ b/backend/open_webui/routers/configs.py @@ -100,7 +100,9 @@ async def set_tool_servers_config( form_data: ToolServersConfigForm, user=Depends(get_admin_user), ): - request.app.state.config.TOOL_SERVER_CONNECTIONS = form_data.TOOL_SERVER_CONNECTIONS + request.app.state.config.TOOL_SERVER_CONNECTIONS = [ + connection.model_dump() for connection in form_data.TOOL_SERVER_CONNECTIONS + ] request.app.state.TOOL_SERVERS = await get_tool_servers_data( request.app.state.config.TOOL_SERVER_CONNECTIONS diff --git a/src/lib/components/admin/Settings/Tools.svelte b/src/lib/components/admin/Settings/Tools.svelte index 7e1c6b03e..d59621be5 100644 --- a/src/lib/components/admin/Settings/Tools.svelte +++ b/src/lib/components/admin/Settings/Tools.svelte @@ -15,6 +15,7 @@ import Connection from '$lib/components/chat/Settings/Tools/Connection.svelte'; import AddServerModal from '$lib/components/AddServerModal.svelte'; + import { getToolServerConnections, setToolServerConnections } from '$lib/apis/configs'; export let saveSettings: Function; @@ -26,10 +27,23 @@ await updateHandler(); }; - const updateHandler = async () => {}; + const updateHandler = async () => { + const res = await setToolServerConnections(localStorage.token, { + TOOL_SERVER_CONNECTIONS: servers + }).catch((err) => { + toast.error($i18n.t('Failed to save connections')); + + return null; + }); + + if (res) { + toast.success($i18n.t('Connections saved successfully')); + } + }; onMount(async () => { - servers = []; + const res = await getToolServerConnections(localStorage.token); + servers = res.TOOL_SERVER_CONNECTIONS; });