reflex-examples icon indicating copy to clipboard operation
reflex-examples copied to clipboard

Stop streaming button for chat_v2

Open johschmidt42 opened this issue 5 months ago • 1 comments

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

johschmidt42 avatar Jun 24 '25 11:06 johschmidt42