Handle unset event in chat response stream

Testing unset event field is an edge case that would unnecessarily
prematurely terminate stream. Ignoring it stabilizes response stream
completion.
This commit is contained in:
Debanjum
2025-12-04 22:15:13 -08:00
parent bdf9afa726
commit f1337c3b07

View File

@@ -1621,7 +1621,9 @@ async def process_chat_request(
interrupt_queue,
)
async for event in response_iterator:
if event.startswith("{") and event.endswith("}"):
if not event:
continue
elif event.startswith("{") and event.endswith("}"):
evt_json = json.loads(event)
if evt_json["type"] == ChatEvent.END_LLM_RESPONSE.value:
# Flush remaining buffer content on end llm response event