Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /Chainlit_chainlit /cypress /e2e /action /main.py
| import chainlit as cl | |
| async def on_test_action(): | |
| await cl.Message(content="Executed test action!").send() | |
| async def on_removable_action(action: cl.Action): | |
| await cl.Message(content="Executed removable action!").send() | |
| await action.remove() | |
| async def on_multiple_actions(action: cl.Action): | |
| await cl.Message(content=f"Action(id={action.id}) has been removed!").send() | |
| await action.remove() | |
| async def on_all_actions_removed(_: cl.Action): | |
| await cl.Message(content="All actions have been removed!").send() | |
| to_remove = cl.user_session.get("to_remove") # type: cl.Message | |
| await to_remove.remove_actions() | |
| async def main(): | |
| actions = [ | |
| cl.Action(id="test-action", name="test action", payload={"value": "test"}), | |
| cl.Action( | |
| id="removable-action", name="removable action", payload={"value": "test"} | |
| ), | |
| cl.Action( | |
| id="label-action", | |
| name="label action", | |
| payload={"value": "test"}, | |
| label="Test Label", | |
| ), | |
| cl.Action( | |
| id="multiple-action-one", | |
| name="multiple actions", | |
| payload={"value": "multiple action one"}, | |
| label="multiple action one", | |
| ), | |
| cl.Action( | |
| id="multiple-action-two", | |
| name="multiple actions", | |
| payload={"value": "multiple action two"}, | |
| label="multiple action two", | |
| ), | |
| cl.Action( | |
| id="all-actions-removed", | |
| name="all actions removed", | |
| payload={"value": "test"}, | |
| ), | |
| ] | |
| message = cl.Message("Hello, this is a test message!", actions=actions) | |
| cl.user_session.set("to_remove", message) | |
| await message.send() | |
| result = await cl.AskActionMessage( | |
| content="Please, pick an action!", | |
| actions=[ | |
| cl.Action( | |
| id="first-action", | |
| name="first_action", | |
| payload={"value": "first-action"}, | |
| label="First action", | |
| ), | |
| cl.Action( | |
| id="second-action", | |
| name="second_action", | |
| payload={"value": "second-action"}, | |
| label="Second action", | |
| ), | |
| ], | |
| ).send() | |
| if result is not None: | |
| await cl.Message(f"Thanks for pressing: {result['payload']['value']}").send() | |
Xet Storage Details
- Size:
- 2.56 kB
- Xet hash:
- 45452ff4e39b8cc3305eb53a614d136b158f8ea2cd0d21946d630c474cd632c4
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.