This commit is contained in:
Timothy Jaeryang Baek
2026-07-23 23:16:28 -04:00
parent 866e8582d1
commit 315a6b5995
+13 -2
View File
@@ -57,6 +57,7 @@ from open_webui.routers.images import (
image_generations,
)
from open_webui.routers.pipelines import (
get_sorted_filters,
process_pipeline_inlet_filter,
process_pipeline_outlet_filter,
)
@@ -5437,6 +5438,16 @@ async def streaming_chat_response_handler(response, ctx):
return f'data: {item}\n\n'
assistant_message = {}
has_api_outlet_filters = ENABLE_API_OUTLET_FILTERS and bool(filter_functions)
if ENABLE_API_OUTLET_FILTERS and not has_api_outlet_filters:
try:
model_id = model.get('id') if isinstance(model, dict) else model
has_api_outlet_filters = bool(
(isinstance(model, dict) and 'pipeline' in model)
or get_sorted_filters(model_id, request.app.state.MODELS)
)
except Exception:
has_api_outlet_filters = True
for event in events:
event, _ = await process_filter_functions(
@@ -5460,11 +5471,11 @@ async def streaming_chat_response_handler(response, ctx):
)
if data:
if ENABLE_API_OUTLET_FILTERS:
if has_api_outlet_filters:
update_assistant_message_from_stream(assistant_message, data)
yield data
if ENABLE_API_OUTLET_FILTERS and assistant_message:
if has_api_outlet_filters and assistant_message:
ctx['assistant_message'] = assistant_message
await outlet_filter_handler(ctx)