From f5b2867e458e644ec5a8402848055dba04266763 Mon Sep 17 00:00:00 2001 From: Thomas Rehn <271119+tremlin@users.noreply.github.com> Date: Tue, 8 Apr 2025 12:35:04 +0200 Subject: [PATCH] fix: mismatch between TOOL_SERVERS / TOOL_SERVER_CONNECTIONS indexing --- backend/open_webui/routers/tools.py | 4 ++-- backend/open_webui/utils/tools.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/open_webui/routers/tools.py b/backend/open_webui/routers/tools.py index 8a98b4e20..56ede2208 100644 --- a/backend/open_webui/routers/tools.py +++ b/backend/open_webui/routers/tools.py @@ -45,7 +45,7 @@ async def get_tools(request: Request, user=Depends(get_verified_user)): ) tools = Tools.get_tools() - for idx, server in enumerate(request.app.state.TOOL_SERVERS): + for server in request.app.state.TOOL_SERVERS: tools.append( ToolUserResponse( **{ @@ -60,7 +60,7 @@ async def get_tools(request: Request, user=Depends(get_verified_user)): .get("description", ""), }, "access_control": request.app.state.config.TOOL_SERVER_CONNECTIONS[ - idx + server["idx"] ] .get("config", {}) .get("access_control", None), diff --git a/backend/open_webui/utils/tools.py b/backend/open_webui/utils/tools.py index 734c23e1b..325b55c45 100644 --- a/backend/open_webui/utils/tools.py +++ b/backend/open_webui/utils/tools.py @@ -55,7 +55,12 @@ def get_tools( tool_server_connection = ( request.app.state.config.TOOL_SERVER_CONNECTIONS[server_idx] ) - tool_server_data = request.app.state.TOOL_SERVERS[server_idx] + tool_server_data = None + for server in request.app.state.TOOL_SERVERS: + if server["idx"] == server_idx: + tool_server_data = server + break + assert tool_server_data is not None specs = tool_server_data.get("specs", []) for spec in specs: