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

Merged
merged 9 commits into from
Jan 28, 2025

Conversation

celeriev
Copy link
Contributor

@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
Contributor 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

@hexart
Copy link
Contributor

hexart commented Jan 23, 2025

How is this pr going? Can I make a new request as @willydouhard asked for?

Related issue #1797

@celeriev
Copy link
Contributor Author

It is ready I think to be merged, wdyt @willydouhard @dokterbob

Copy link
Collaborator

@willydouhard willydouhard left a comment

Choose a reason for hiding this comment

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

LGTM

@willydouhard willydouhard added this pull request to the merge queue Jan 28, 2025
Merged via the queue into Chainlit:main with commit e4bdcc0 Jan 28, 2025
9 checks passed
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.

4 participants