Skip to content

Commit c9e2ba5

Browse files
authored
Merge pull request open-webui#11198 from xinhai-ai/refa_filters
chore: move the filter_type check earlier to avoid unnecessary valve reads.
2 parents b01c918 + 3ee1ae8 commit c9e2ba5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

backend/open_webui/utils/filter.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ async def process_filter_functions(
4949
function_module, _, _ = load_function_module_by_id(filter_id)
5050
request.app.state.FUNCTIONS[filter_id] = function_module
5151

52+
# Prepare handler function
53+
handler = getattr(function_module, filter_type, None)
54+
if not handler:
55+
continue
56+
5257
# Check if the function has a file_handler variable
5358
if filter_type == "inlet" and hasattr(function_module, "file_handler"):
5459
skip_files = function_module.file_handler
@@ -60,10 +65,6 @@ async def process_filter_functions(
6065
**(valves if valves else {})
6166
)
6267

63-
# Prepare handler function
64-
handler = getattr(function_module, filter_type, None)
65-
if not handler:
66-
continue
6768

6869
try:
6970
# Prepare parameters

0 commit comments

Comments
 (0)