Chainlit / docs

9 stars 60 forks source link

Loader not working with cl.sleep #100

Open httplups opened 4 months ago

httplups commented 4 months ago

I was following the tutorial to display the loader (running) while awaiting for the response, but it is not working. I just copy the code from the documentation.

import chainlit as cl

@cl.on_chat_start
async def main():
    msg = cl.Message(content="Hello!")
    await msg.send()

    await cl.sleep(2)

    msg.content = "Hello again!"
    await msg.update()

It appears Hello, after a few seconds appears Hello Again, but the loader is not shown

willydouhard commented 4 months ago

It only works while the content is empty.

Replace msg = cl.Message(content="Hello!") with msg = cl.Message(content="").