Add explicit flush after yielding each stream chunk

parent 8a4458a3
...@@ -1556,6 +1556,8 @@ async def stream_chat_response( ...@@ -1556,6 +1556,8 @@ async def stream_chat_response(
}], }],
} }
yield f"data: {json.dumps(data)}\n\n" yield f"data: {json.dumps(data)}\n\n"
# Explicitly flush to ensure data is sent immediately
await asyncio.sleep(0)
print(f"DEBUG: stream_chat_response completed, {chunk_count} chunks, generated_text length: {len(generated_text)}") print(f"DEBUG: stream_chat_response completed, {chunk_count} chunks, generated_text length: {len(generated_text)}")
if not generated_text.strip(): if not generated_text.strip():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment