reflex-examples
reflex-examples copied to clipboard
Stop streaming button for chat_v2
Would it be possible to see a stop button added to the chat?
Reading the docs about background jobs, I came to the conclusion that we need to check if a given variable has been changed while iterating over an async iterator. But is there a better way to this?
Here's some example pseudo using httpx:
async with (
AsyncClient() as client,
client.stream(...) as stream,
):
async with self:
self.is_streaming = True
async for line in stream.aiter_lines():
if not self.is_streaming:
break