Chainlit / cookbook

Chainlit's cookbook repo
https://github.com/Chainlit/chainlit
747 stars 276 forks source link

Use cl.Action on custom frontend #96

Closed croziermaxime closed 3 weeks ago

croziermaxime commented 6 months ago

Hey I'm trying to use the chainlit actions inside the custom frontend like this: image But the 2 actions are not displaying in the frontend when I run it, I guess I have to apply changes directly to the frontend to make it work, but I wonder if the cl.Action method is supported on the @chainlit/react-client module and if so what should I do to make it work.

Thanks !

ModEnter commented 3 weeks ago

Hello, to display actions in a message, you can pass them directly as attribute to the message, as shown in this comprehensive example :

import chainlit as cl

@cl.on_chat_start
async def start():
    # Sending an action button within a chatbot message
    actions = [
        cl.Action(name="action_button", value="example_value", description="Click me!")
    ]

    await cl.Message(content="Interact with this action button:", actions=actions).send()