This commit is contained in:
Timothy Jaeryang Baek
2026-04-13 13:13:45 -05:00
parent 20544d412e
commit 51765b619c
2 changed files with 41 additions and 31 deletions
+15 -13
View File
@@ -1787,11 +1787,12 @@ async def chat_completion(
log.info('Chat processing was cancelled')
try:
event_emitter = await get_event_emitter(metadata)
await asyncio.shield(
event_emitter(
{'type': 'chat:tasks:cancel'},
if event_emitter:
await asyncio.shield(
event_emitter(
{'type': 'chat:tasks:cancel'},
)
)
)
except Exception as e:
pass
finally:
@@ -1812,15 +1813,16 @@ async def chat_completion(
)
event_emitter = await get_event_emitter(metadata)
await event_emitter(
{
'type': 'chat:message:error',
'data': {'error': {'content': str(e)}},
}
)
await event_emitter(
{'type': 'chat:tasks:cancel'},
)
if event_emitter:
await event_emitter(
{
'type': 'chat:message:error',
'data': {'error': {'content': str(e)}},
}
)
await event_emitter(
{'type': 'chat:tasks:cancel'},
)
except Exception:
pass