This commit is contained in:
Timothy Jaeryang Baek 2026-08-25 15:26:45 -04:00
parent e3a7a64d82
commit 28f2965934

View file

@ -3836,7 +3836,8 @@ async def outlet_filter_handler(ctx):
Replaces the separate POST /api/chat/completed round-trip.
Persists outlet-modified content to DB and emits a chat:outlet event
so the frontend can sync its in-memory state.
so the frontend can sync its in-memory state. Returns immediately when
the model has no filters.
For temp/API chats, messages are built from form_data plus ctx['assistant_message'].
"""
@ -3858,6 +3859,17 @@ async def outlet_filter_handler(ctx):
is_unsaved_chat = not is_saved_chat_id(chat_id)
try:
filter_functions = (
await get_filter_functions(request, model, metadata.get('filter_ids', [])) if ENABLE_PLUGINS else []
)
model_id = model.get('id') if isinstance(model, dict) else model
models = request.app.state.MODELS
has_pipeline_outlet_filters = bool(
(isinstance(model, dict) and 'pipeline' in model) or get_sorted_filters(model_id, models)
)
if not filter_functions and not has_pipeline_outlet_filters:
return
messages_map = None
if is_unsaved_chat:
@ -3892,8 +3904,6 @@ async def outlet_filter_handler(ctx):
if not message_list:
return
model_id = model.get('id') if isinstance(model, dict) else model
outlet_data = {
'model': model_id,
'messages': [
@ -3917,7 +3927,6 @@ async def outlet_filter_handler(ctx):
}
# Pipeline outlet filters
models = request.app.state.MODELS
try:
outlet_data = await process_pipeline_outlet_filter(request, outlet_data, user, models)
except Exception as e:
@ -3933,9 +3942,7 @@ async def outlet_filter_handler(ctx):
'__model__': model,
}
if ENABLE_PLUGINS:
filter_functions = await get_filter_functions(request, model, metadata.get('filter_ids', []))
if filter_functions:
outlet_result, _ = await process_filter_functions(
request=request,
filter_context=None,