Skip to content

Commit 4856ce4

Browse files
committed
chore: format
1 parent 0037bae commit 4856ce4

4 files changed

Lines changed: 26 additions & 15 deletions

File tree

backend/open_webui/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1796,7 +1796,9 @@ async def chat_completion(
17961796

17971797
if metadata.get('chat_id') and user:
17981798
chat_id = metadata['chat_id']
1799-
if not chat_id.startswith('local:') and not chat_id.startswith('channel:'): # temporary/channel chats are not stored
1799+
if not chat_id.startswith('local:') and not chat_id.startswith(
1800+
'channel:'
1801+
): # temporary/channel chats are not stored
18001802
if is_new_chat:
18011803
# Build the full history upfront with ALL assistant placeholders
18021804
user_message = metadata.get('user_message') or {}

backend/open_webui/routers/channels.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
)
6060

6161

62-
6362
from open_webui.utils.auth import get_admin_user, get_verified_user
6463
from open_webui.utils.access_control import has_permission, filter_allowed_access_grants
6564
from open_webui.utils.webhook import post_webhook
@@ -1017,9 +1016,7 @@ async def model_response_handler(request, channel, message, user, db=None):
10171016
# tools, filters, RAG — everything. The pipeline runs as
10181017
# an async task; the channel emitter handles progressive
10191018
# message updates via socket events.
1020-
await request.app.state.CHAT_COMPLETION_HANDLER(
1021-
request, form_data, user=user
1022-
)
1019+
await request.app.state.CHAT_COMPLETION_HANDLER(request, form_data, user=user)
10231020

10241021
except Exception as e:
10251022
log.exception(e)

backend/open_webui/socket/main.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -891,11 +891,7 @@ async def __channel_emitter__(event_data):
891891

892892
elif event_type == 'chat:message:error':
893893
error = event_data.get('data', {}).get('error', {})
894-
error_content = (
895-
error.get('content', 'An error occurred')
896-
if isinstance(error, dict)
897-
else str(error)
898-
)
894+
error_content = error.get('content', 'An error occurred') if isinstance(error, dict) else str(error)
899895
await _emit_channel_update(f'Error: {error_content}', done=True)
900896

901897
return __channel_emitter__

backend/open_webui/utils/middleware.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3058,7 +3058,11 @@ async def background_tasks_handler(ctx):
30583058
message = None
30593059
messages = []
30603060

3061-
if 'chat_id' in metadata and not metadata['chat_id'].startswith('local:') and not metadata['chat_id'].startswith('channel:'):
3061+
if (
3062+
'chat_id' in metadata
3063+
and not metadata['chat_id'].startswith('local:')
3064+
and not metadata['chat_id'].startswith('channel:')
3065+
):
30623066
messages_map = await Chats.get_messages_map_by_chat_id(metadata['chat_id'])
30633067
message = messages_map.get(metadata['message_id']) if messages_map else None
30643068

@@ -3138,7 +3142,9 @@ async def background_tasks_handler(ctx):
31383142
}
31393143
)
31403144

3141-
if not metadata.get('chat_id', '').startswith('local:') and not metadata.get('chat_id', '').startswith('channel:'):
3145+
if not metadata.get('chat_id', '').startswith('local:') and not metadata.get(
3146+
'chat_id', ''
3147+
).startswith('channel:'):
31423148
await Chats.upsert_message_to_chat_by_id_and_message_id(
31433149
metadata['chat_id'],
31443150
metadata['message_id'],
@@ -3150,7 +3156,9 @@ async def background_tasks_handler(ctx):
31503156
except Exception as e:
31513157
pass
31523158

3153-
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
3159+
if not metadata.get('chat_id', '').startswith('local:') and not metadata.get('chat_id', '').startswith(
3160+
'channel:'
3161+
): # Only update titles and tags for non-temp chats
31543162
if TASKS.TITLE_GENERATION in tasks:
31553163
user_message = get_last_user_message(messages)
31563164
if user_message and len(user_message) > 100:
@@ -3453,7 +3461,11 @@ async def non_streaming_chat_response_handler(response, ctx):
34533461
}
34543462
)
34553463

3456-
title = await Chats.get_chat_title_by_id(metadata['chat_id']) if not metadata['chat_id'].startswith('channel:') else ''
3464+
title = (
3465+
await Chats.get_chat_title_by_id(metadata['chat_id'])
3466+
if not metadata['chat_id'].startswith('channel:')
3467+
else ''
3468+
)
34573469

34583470
# Use output from backend if provided (OR-compliant backends),
34593471
# otherwise generate from response content
@@ -5026,7 +5038,11 @@ async def restricted_import(name, globals=None, locals=None, fromlist=(), level=
50265038
if item.get('status') == 'in_progress':
50275039
item['status'] = 'completed'
50285040

5029-
title = await Chats.get_chat_title_by_id(metadata['chat_id']) if not metadata['chat_id'].startswith('channel:') else ''
5041+
title = (
5042+
await Chats.get_chat_title_by_id(metadata['chat_id'])
5043+
if not metadata['chat_id'].startswith('channel:')
5044+
else ''
5045+
)
50305046
data = {
50315047
'done': True,
50325048
'content': serialize_output(output),

0 commit comments

Comments
 (0)