b7f52be4c9
CI / Run CI (push) Has been cancelled
CI / check-backend (push) Has been cancelled
CI / check-frontend (push) Has been cancelled
CI / tests (push) Has been cancelled
CI / e2e-tests (push) Has been cancelled
Copilot Setup Steps / copilot-setup-steps (push) Has been cancelled
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
import chainlit as cl
|
|
|
|
commands = [
|
|
{"id": "Picture", "icon": "image", "description": "Use DALL-E"},
|
|
{"id": "Search", "icon": "globe", "description": "Find on the web", "button": True},
|
|
{
|
|
"id": "Canvas",
|
|
"icon": "pen-line",
|
|
"description": "Collaborate on writing and code",
|
|
},
|
|
{
|
|
"id": "Sticky",
|
|
"icon": "pin",
|
|
"description": "Persistent tool stays selected",
|
|
"persistent": True,
|
|
},
|
|
{
|
|
"id": "StickyButton",
|
|
"icon": "bookmark",
|
|
"description": "Persistent button tool",
|
|
"button": True,
|
|
"persistent": True,
|
|
},
|
|
]
|
|
|
|
|
|
@cl.on_chat_start
|
|
async def start():
|
|
await cl.context.emitter.set_commands(commands)
|
|
|
|
|
|
@cl.on_message
|
|
async def message(msg: cl.Message):
|
|
# Clear all commands after choosing Picture to test UI behavior with zero commands
|
|
# This simulates a scenario where certain commands might change the available tool set
|
|
if msg.command == "Picture":
|
|
await cl.context.emitter.set_commands([])
|
|
|
|
await cl.Message(content=f"Command: {msg.command}").send()
|