You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Action buttons (cl.Action) included in the assistant's message are not being persisted in the data storage. This causes issues when attempting to retrieve or reference these action messages later on.
To Reproduce
Steps to reproduce the behavior:
Implement a function that sends a message containing action buttons. For example:
import chainlit as cl
@cl.step(name="Handle New Question", show_input=False)
async def handle_new_question():
# Generate assistant's response
response = "Here is the response to your question."
# Create action buttons
actions = [
cl.Action(name="action_button", value="Option 1", label="Option 1"),
cl.Action(name="action_button", value="Option 2", label="Option 2"),
cl.Action(name="action_button", value="Option 3", label="Option 3"),
]
# Send the assistant's message with action buttons
assistant_message = await cl.Message(
content=response,
actions=actions,
type="assistant_message",
author="assistant"
).send()
# Attempt to store the message using its ID
message_store[assistant_message.id] = {
'response': response,
'actions': [action.value for action in actions]
}
Run the application and trigger the handle_new_question function by sending a user message.
Expected behavior
All messages sent by the assistant, including those containing action buttons (cl.Action), should be properly stored, so they can be persisted and referenced later.
Question:
How can I ensure that messages containing action buttons are properly persisted in the data storage when using Chainlit?
Is there a recommended way to capture and store these messages so they can be referenced later?
Any guidance or suggestions on how to resolve this issue would be greatly appreciated. Thank you!
The text was updated successfully, but these errors were encountered:
I found a similar issue that was discussed previously. The solution involves using the Message class and its methods to ensure that messages containing action buttons (cl.Action) are properly persisted in the data storage. Here's a brief overview of how you can achieve this:
Create a Message with Actions: Instantiate a Message object with the desired content and actions.
Send the Message: Use the send method of the Message class to send the message to the UI and persist it. This method will also handle sending the associated actions.
Persistence: The send method internally calls _create, which attempts to persist the message using the data layer if it is configured. If a project ID is configured, the messages will be uploaded to the cloud storage.
Here's an example code snippet:
importchainlitascl# Define your actionsactions= [
cl.Action(name="action1", value="action1", label="Action 1"),
cl.Action(name="action2", value="action2", label="Action 2")
]
# Create a message with actionsmessage=cl.Message(
content="This is a message with actions.",
actions=actions
)
# Send the message and persist itawaitmessage.send()
This approach ensures that the message and its associated actions are sent to the UI and persisted in the data storage, provided that the data layer is properly configured [1][2].
Describe the bug
Action buttons (cl.Action) included in the assistant's message are not being persisted in the data storage. This causes issues when attempting to retrieve or reference these action messages later on.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
All messages sent by the assistant, including those containing action buttons (cl.Action), should be properly stored, so they can be persisted and referenced later.
Question:
How can I ensure that messages containing action buttons are properly persisted in the data storage when using Chainlit?
Is there a recommended way to capture and store these messages so they can be referenced later?
Any guidance or suggestions on how to resolve this issue would be greatly appreciated. Thank you!
The text was updated successfully, but these errors were encountered: