chore: format

This commit is contained in:
Timothy Jaeryang Baek
2026-05-11 02:51:59 +09:00
parent 0037baeb26
commit 4856ce48be
4 changed files with 26 additions and 15 deletions

View File

@@ -1796,7 +1796,9 @@ async def chat_completion(
if metadata.get('chat_id') and user:
chat_id = metadata['chat_id']
if not chat_id.startswith('local:') and not chat_id.startswith('channel:'): # temporary/channel chats are not stored
if not chat_id.startswith('local:') and not chat_id.startswith(
'channel:'
): # temporary/channel chats are not stored
if is_new_chat:
# Build the full history upfront with ALL assistant placeholders
user_message = metadata.get('user_message') or {}

View File

@@ -59,7 +59,6 @@ from open_webui.utils.models import (
)
from open_webui.utils.auth import get_admin_user, get_verified_user
from open_webui.utils.access_control import has_permission, filter_allowed_access_grants
from open_webui.utils.webhook import post_webhook
@@ -1017,9 +1016,7 @@ async def model_response_handler(request, channel, message, user, db=None):
# tools, filters, RAG — everything. The pipeline runs as
# an async task; the channel emitter handles progressive
# message updates via socket events.
await request.app.state.CHAT_COMPLETION_HANDLER(
request, form_data, user=user
)
await request.app.state.CHAT_COMPLETION_HANDLER(request, form_data, user=user)
except Exception as e:
log.exception(e)

View File

@@ -891,11 +891,7 @@ async def _make_channel_emitter(request_info):
elif event_type == 'chat:message:error':
error = event_data.get('data', {}).get('error', {})
error_content = (
error.get('content', 'An error occurred')
if isinstance(error, dict)
else str(error)
)
error_content = error.get('content', 'An error occurred') if isinstance(error, dict) else str(error)
await _emit_channel_update(f'Error: {error_content}', done=True)
return __channel_emitter__

View File

@@ -3058,7 +3058,11 @@ async def background_tasks_handler(ctx):
message = None
messages = []
if 'chat_id' in metadata and not metadata['chat_id'].startswith('local:') and not metadata['chat_id'].startswith('channel:'):
if (
'chat_id' in metadata
and not metadata['chat_id'].startswith('local:')
and not metadata['chat_id'].startswith('channel:')
):
messages_map = await Chats.get_messages_map_by_chat_id(metadata['chat_id'])
message = messages_map.get(metadata['message_id']) if messages_map else None
@@ -3138,7 +3142,9 @@ async def background_tasks_handler(ctx):
}
)
if not metadata.get('chat_id', '').startswith('local:') and not metadata.get('chat_id', '').startswith('channel:'):
if not metadata.get('chat_id', '').startswith('local:') and not metadata.get(
'chat_id', ''
).startswith('channel:'):
await Chats.upsert_message_to_chat_by_id_and_message_id(
metadata['chat_id'],
metadata['message_id'],
@@ -3150,7 +3156,9 @@ async def background_tasks_handler(ctx):
except Exception as e:
pass
if not metadata.get('chat_id', '').startswith('local:') and not metadata.get('chat_id', '').startswith('channel:'): # Only update titles and tags for non-temp chats
if not metadata.get('chat_id', '').startswith('local:') and not metadata.get('chat_id', '').startswith(
'channel:'
): # Only update titles and tags for non-temp chats
if TASKS.TITLE_GENERATION in tasks:
user_message = get_last_user_message(messages)
if user_message and len(user_message) > 100:
@@ -3453,7 +3461,11 @@ async def non_streaming_chat_response_handler(response, ctx):
}
)
title = await Chats.get_chat_title_by_id(metadata['chat_id']) if not metadata['chat_id'].startswith('channel:') else ''
title = (
await Chats.get_chat_title_by_id(metadata['chat_id'])
if not metadata['chat_id'].startswith('channel:')
else ''
)
# Use output from backend if provided (OR-compliant backends),
# otherwise generate from response content
@@ -5026,7 +5038,11 @@ async def streaming_chat_response_handler(response, ctx):
if item.get('status') == 'in_progress':
item['status'] = 'completed'
title = await Chats.get_chat_title_by_id(metadata['chat_id']) if not metadata['chat_id'].startswith('channel:') else ''
title = (
await Chats.get_chat_title_by_id(metadata['chat_id'])
if not metadata['chat_id'].startswith('channel:')
else ''
)
data = {
'done': True,
'content': serialize_output(output),