This commit is contained in:
Timothy Jaeryang Baek
2026-04-14 16:08:14 -05:00
parent f102060a6d
commit a4ed16999e
2 changed files with 15 additions and 10 deletions
+13 -5
View File
@@ -583,7 +583,7 @@ from open_webui.tasks import (
from open_webui.utils.redis import get_sentinels_from_env
from open_webui.constants import ERROR_MESSAGES
from open_webui.constants import ERROR_MESSAGES, TASKS
if SAFE_MODE:
print('SAFE MODE ENABLED')
@@ -1827,7 +1827,7 @@ async def chat_completion(
detail=str(e),
)
async def process_chat(request, form_data, user, metadata, model):
async def process_chat(request, form_data, user, metadata, model, tasks=None):
try:
form_data, metadata, events = await process_chat_payload(request, form_data, user, metadata, model)
@@ -1931,7 +1931,7 @@ async def chat_completion(
task_ids = []
chat_id = metadata['chat_id']
for target_model_id, assistant_message_id in message_ids.items():
for idx, (target_model_id, assistant_message_id) in enumerate(message_ids.items()):
if not assistant_message_id:
continue
@@ -1951,9 +1951,17 @@ async def chat_completion(
# Resolve the model object for this specific model
resolved_model = request.app.state.MODELS.get(target_model_id, model)
# Only the first model runs title/tags generation;
# subsequent models only run follow-ups.
task_id, _ = await create_task(
request.app.state.redis,
process_chat(request, model_form_data, user, per_model_metadata, resolved_model),
process_chat(
request, model_form_data, user, per_model_metadata, resolved_model,
tasks if idx == 0 else {
k: v for k, v in (tasks or {}).items()
if k not in (TASKS.TITLE_GENERATION, TASKS.TAGS_GENERATION)
} or None,
),
id=chat_id,
)
task_ids.append(task_id)
@@ -1975,7 +1983,7 @@ async def chat_completion(
else:
# Legacy/direct: single model, synchronous
metadata['message_id'] = list(message_ids.values())[0]
return await process_chat(request, form_data, user, metadata, model)
return await process_chat(request, form_data, user, metadata, model, tasks)
# Alias for chat_completion (Legacy)
+2 -5
View File
@@ -2345,11 +2345,8 @@
background_tasks: {
...(!$temporaryChatEnabled &&
(messages.length == 1 ||
(messages.length == 2 &&
messages.at(0)?.role === 'system' &&
messages.at(1)?.role === 'user')) &&
(selectedModels[0] === model.id || atSelectedModel !== undefined)
!_chatId &&
(userMessage?.parentId ?? null) === null
? {
title_generation: $settings?.title?.auto ?? true,
tags_generation: $settings?.autoTags ?? true