refac
This commit is contained in:
@@ -1877,7 +1877,8 @@ async def chat_completion(
|
||||
finally:
|
||||
raise # re-raise to ensure proper task cancellation handling
|
||||
except Exception as e:
|
||||
log.error('Error processing chat payload: %s', e)
|
||||
error_detail = e.detail if isinstance(e, HTTPException) else str(e)
|
||||
log.error('Error processing chat payload: %s', error_detail)
|
||||
if metadata.get('chat_id') and metadata.get('message_id'):
|
||||
# Update the chat message with the error
|
||||
try:
|
||||
@@ -1887,7 +1888,7 @@ async def chat_completion(
|
||||
metadata['message_id'],
|
||||
{
|
||||
'parentId': metadata.get('user_message_id', None),
|
||||
'error': {'content': str(e)},
|
||||
'error': {'content': error_detail},
|
||||
},
|
||||
)
|
||||
|
||||
@@ -1896,7 +1897,7 @@ async def chat_completion(
|
||||
await event_emitter(
|
||||
{
|
||||
'type': 'chat:message:error',
|
||||
'data': {'error': {'content': str(e)}},
|
||||
'data': {'error': {'content': error_detail}},
|
||||
}
|
||||
)
|
||||
await event_emitter(
|
||||
|
||||
Reference in New Issue
Block a user