Files
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 12:48:47 +08:00

33 lines
988 B
Python

import os
import chainlit as cl
# Get the directory where the current script is located
current_directory = os.path.dirname(os.path.abspath(__file__))
# Construct the absolute path to the image and pdf files
cat_image_path = os.path.join(current_directory, "cat.jpeg")
pdf_path = os.path.join(current_directory, "dummy.pdf")
@cl.on_chat_start
async def start():
elements = [
cl.Image(path=cat_image_path, name="image1"),
cl.Pdf(path=pdf_path, name="pdf1"),
cl.Text(content="Here is a side text document", name="text1"),
cl.Text(content="Here is a page text document", name="text2"),
]
await cl.ElementSidebar.set_elements(elements)
await cl.ElementSidebar.set_title("Test title")
@cl.on_message
async def message(msg: cl.Message):
await cl.ElementSidebar.set_elements([cl.Text(content="Text changed!")])
await cl.ElementSidebar.set_title("Title changed!")
await cl.sleep(2)
await cl.ElementSidebar.set_elements([])