From 8ce6c8cf78c23c787926419d53290f9a7067b1a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E6=B5=B7?= <62863922+xinhai-ai@users.noreply.github.com> Date: Wed, 5 Mar 2025 13:00:45 +0800 Subject: [PATCH 1/2] refac: filters --- backend/open_webui/utils/filter.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/open_webui/utils/filter.py b/backend/open_webui/utils/filter.py index f8bac54fa..5df734364 100644 --- a/backend/open_webui/utils/filter.py +++ b/backend/open_webui/utils/filter.py @@ -49,6 +49,11 @@ async def process_filter_functions( function_module, _, _ = load_function_module_by_id(filter_id) request.app.state.FUNCTIONS[filter_id] = function_module + # Prepare handler function + handler = getattr(function_module, filter_type, None) + if not handler: + continue + # Check if the function has a file_handler variable if filter_type == "inlet" and hasattr(function_module, "file_handler"): skip_files = function_module.file_handler @@ -60,10 +65,6 @@ async def process_filter_functions( **(valves if valves else {}) ) - # Prepare handler function - handler = getattr(function_module, filter_type, None) - if not handler: - continue try: # Prepare parameters From 3ee1ae8c95fc7e3e21418c0549bec9bce5d482f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E6=B5=B7?= <62863922+xinhai-ai@users.noreply.github.com> Date: Wed, 5 Mar 2025 13:05:14 +0800 Subject: [PATCH 2/2] refac: filters --- backend/open_webui/utils/filter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/open_webui/utils/filter.py b/backend/open_webui/utils/filter.py index 5df734364..8a7b26773 100644 --- a/backend/open_webui/utils/filter.py +++ b/backend/open_webui/utils/filter.py @@ -52,7 +52,7 @@ async def process_filter_functions( # Prepare handler function handler = getattr(function_module, filter_type, None) if not handler: - continue + continue # Check if the function has a file_handler variable if filter_type == "inlet" and hasattr(function_module, "file_handler"):