mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-11 20:05:19 +00:00
refac
This commit is contained in:
parent
743199f2d0
commit
f0c7bd3f79
3 changed files with 15 additions and 12 deletions
|
|
@ -1409,9 +1409,12 @@ 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
|
||||
function_name_filter_list = (
|
||||
mcp_server_connection.get("config", {})
|
||||
.get("function_name_filter_list", "")
|
||||
.split(",")
|
||||
)
|
||||
|
||||
tool_specs = await mcp_clients[server_id].list_tool_specs()
|
||||
for tool_spec in tool_specs:
|
||||
|
||||
|
|
@ -1424,9 +1427,7 @@ 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 function_name_filter_list:
|
||||
if not is_string_allowed(
|
||||
tool_spec["name"], function_name_filter_list
|
||||
):
|
||||
|
|
|
|||
|
|
@ -35,10 +35,10 @@ def get_allow_block_lists(filter_list):
|
|||
for d in filter_list:
|
||||
if d.startswith("!"):
|
||||
# Domains starting with "!" → blocked
|
||||
block_list.append(d[1:])
|
||||
block_list.append(d[1:].strip())
|
||||
else:
|
||||
# Domains starting without "!" → allowed
|
||||
allow_list.append(d)
|
||||
allow_list.append(d.strip())
|
||||
|
||||
return allow_list, block_list
|
||||
|
||||
|
|
@ -54,6 +54,8 @@ def is_string_allowed(string: str, filter_list: Optional[list[str]] = None) -> b
|
|||
return True
|
||||
|
||||
allow_list, block_list = get_allow_block_lists(filter_list)
|
||||
print(string, allow_list, block_list)
|
||||
|
||||
# If allow list is non-empty, require domain to match one of them
|
||||
if allow_list:
|
||||
if not any(string.endswith(allowed) for allowed in allow_list):
|
||||
|
|
|
|||
|
|
@ -150,15 +150,15 @@ async def get_tools(
|
|||
)
|
||||
|
||||
specs = tool_server_data.get("specs", [])
|
||||
function_name_filter_list = tool_server_connection.get(
|
||||
"function_name_filter_list", None
|
||||
function_name_filter_list = (
|
||||
tool_server_connection.get("config", {})
|
||||
.get("function_name_filter_list", "")
|
||||
.split(",")
|
||||
)
|
||||
|
||||
for spec in specs:
|
||||
function_name = spec["name"]
|
||||
if function_name_filter_list and isinstance(
|
||||
function_name_filter_list, list
|
||||
):
|
||||
if function_name_filter_list:
|
||||
if not is_string_allowed(
|
||||
function_name, function_name_filter_list
|
||||
):
|
||||
|
|
|
|||
Loading…
Reference in a new issue