Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow sending toast notifications #1736

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

celeriev
Copy link

@celeriev celeriev commented Jan 17, 2025

Enable sending toast notification from chainlit app

Related to #1639

# This is a simple example of a chainlit app.

from chainlit import AskUserMessage, Message, on_chat_start
import chainlit as cl

@on_chat_start
async def main():
    res = await AskUserMessage(content="What is your name?", timeout=30).send()
    if res:
        await cl.context.emitter.send_toast(message=f"Hello {res['output']}!")
        await cl.context.emitter.send_toast(message=f"Hello {res['output']}!", type="error")
Screenshot 2025-01-19 at 19 21 22 Screenshot 2025-01-19 at 19 23 50

This is my first PR 🥳

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request frontend Pertains to the frontend. labels Jan 17, 2025
@willydouhard
Copy link
Collaborator

This is looking great! I think we could add a function on the emitter class with typing on top of cl.context.emitter.emit("toast" to make it more discoverable and usable.

@@ -69,7 +69,7 @@ function App() {
storageKey="vite-ui-theme"
defaultTheme={data?.default_theme}
>
<Toaster className="toast" position="top-right" />
<Toaster richColors className="toast" position="top-right" />
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@willydouhard I added the richColors settings, let me know what you think, I think it goes quite well with chainlit look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request frontend Pertains to the frontend. size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants