Skip to content

Commit a1b7b9b

Browse files
Copilotowndev
andcommitted
Fix Gemini streaming response not persisted when leaving chat
Add yield final_content at end of successful streaming to ensure the async iterator completes properly and the response is persisted even when the user navigates away during streaming. Co-authored-by: owndev <69784886+owndev@users.noreply.github.com>
1 parent 8062ed3 commit a1b7b9b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pipelines/google/google_gemini.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,6 +2052,10 @@ async def emit_chat_event(event_type: str, data: Dict[str, Any]) -> None:
20522052
{"role": "assistant", "content": final_content, "done": True},
20532053
)
20542054

2055+
# Yield final content to ensure the async iterator completes properly.
2056+
# This ensures the response is persisted even if the user navigates away.
2057+
yield final_content
2058+
20552059
except Exception as e:
20562060
self.log.exception(f"Error during streaming: {e}")
20572061
# Check if it's a chunk size error and provide specific guidance

0 commit comments

Comments
 (0)