@@ -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