Skip to content

streaming chat messages #4142

Closed Answered by rodja
patrickwasp asked this question in Q&A
Discussion options

You must be logged in to vote

There is no need for the refreshable. Simply update the html element which represents the content of the message:

class ChatDemo:
    def __init__(self):
        self.container = ui.column()
        self.current_message = None
        self.setup_ui()

    def setup_ui(self):
        with self.container:
            ui.button("Send message", on_click=self.send)

    async def mock_stream(self):
        """Simulate streaming response"""
        response = "Hello! This is a test message that should stream word by word."
        for word in response.split():
            yield word + " "
            await asyncio.sleep(0.5)

    async def send(self):
        # Create message immediately with l…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by patrickwasp
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants