mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-04 19:29:27 -05:00
feat/enh: tool server function name filter list
This commit is contained in:
@@ -24,6 +24,7 @@ from fastapi.responses import HTMLResponse
|
||||
from starlette.responses import Response, StreamingResponse, JSONResponse
|
||||
|
||||
|
||||
from open_webui.utils.misc import is_string_allowed
|
||||
from open_webui.models.oauth_sessions import OAuthSessions
|
||||
from open_webui.models.chats import Chats
|
||||
from open_webui.models.folders import Folders
|
||||
@@ -1408,6 +1409,9 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
||||
headers=headers if headers else None,
|
||||
)
|
||||
|
||||
function_name_filter_list = mcp_server_connection.get(
|
||||
"function_name_filter_list", None
|
||||
)
|
||||
tool_specs = await mcp_clients[server_id].list_tool_specs()
|
||||
for tool_spec in tool_specs:
|
||||
|
||||
@@ -1420,6 +1424,15 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
||||
|
||||
return tool_function
|
||||
|
||||
if function_name_filter_list and isinstance(
|
||||
function_name_filter_list, list
|
||||
):
|
||||
if not is_string_allowed(
|
||||
tool_spec["name"], function_name_filter_list
|
||||
):
|
||||
# Skip this function
|
||||
continue
|
||||
|
||||
tool_function = make_tool_function(
|
||||
mcp_clients[server_id], tool_spec["name"]
|
||||
)
|
||||
@@ -1460,6 +1473,7 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
||||
"__files__": metadata.get("files", []),
|
||||
},
|
||||
)
|
||||
|
||||
if mcp_tools_dict:
|
||||
tools_dict = {**tools_dict, **mcp_tools_dict}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user