mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
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:
@@ -1621,7 +1621,9 @@ async def process_chat_request(
|
|||||||
interrupt_queue,
|
interrupt_queue,
|
||||||
)
|
)
|
||||||
async for event in response_iterator:
|
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)
|
evt_json = json.loads(event)
|
||||||
if evt_json["type"] == ChatEvent.END_LLM_RESPONSE.value:
|
if evt_json["type"] == ChatEvent.END_LLM_RESPONSE.value:
|
||||||
# Flush remaining buffer content on end llm response event
|
# Flush remaining buffer content on end llm response event
|
||||||
|
|||||||
Reference in New Issue
Block a user