mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 20:07:49 +01:00
refac
This commit is contained in:
@@ -416,15 +416,19 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
|
||||
)
|
||||
return 0
|
||||
|
||||
filter_ids = [
|
||||
function.id
|
||||
for function in Functions.get_functions_by_type(
|
||||
"filter", active_only=True
|
||||
)
|
||||
]
|
||||
# Check if the model has any filters
|
||||
filter_ids = []
|
||||
if "info" in model and "meta" in model["info"]:
|
||||
filter_ids.extend(model["info"]["meta"].get("filterIds", []))
|
||||
enabled_filter_ids = [
|
||||
function.id
|
||||
for function in Functions.get_functions_by_type(
|
||||
"filter", active_only=True
|
||||
)
|
||||
]
|
||||
filter_ids = [
|
||||
filter_id
|
||||
for filter_id in enabled_filter_ids
|
||||
if filter_id in model["info"]["meta"].get("filterIds", [])
|
||||
]
|
||||
filter_ids = list(set(filter_ids))
|
||||
|
||||
filter_ids.sort(key=get_priority)
|
||||
@@ -1006,13 +1010,19 @@ async def chat_completed(form_data: dict, user=Depends(get_verified_user)):
|
||||
return (function.valves if function.valves else {}).get("priority", 0)
|
||||
return 0
|
||||
|
||||
filter_ids = [
|
||||
function.id
|
||||
for function in Functions.get_functions_by_type("filter", active_only=True)
|
||||
]
|
||||
# Check if the model has any filters
|
||||
filter_ids = []
|
||||
if "info" in model and "meta" in model["info"]:
|
||||
filter_ids.extend(model["info"]["meta"].get("filterIds", []))
|
||||
enabled_filter_ids = [
|
||||
function.id
|
||||
for function in Functions.get_functions_by_type(
|
||||
"filter", active_only=True
|
||||
)
|
||||
]
|
||||
filter_ids = [
|
||||
filter_id
|
||||
for filter_id in enabled_filter_ids
|
||||
if filter_id in model["info"]["meta"].get("filterIds", [])
|
||||
]
|
||||
filter_ids = list(set(filter_ids))
|
||||
|
||||
# Sort filter_ids by priority, using the get_priority function
|
||||
|
||||
Reference in New Issue
Block a user