The Pdf class allows you to display a PDF hosted remotely or locally in the chatbot UI. This class either takes a URL of a PDF hosted online, or the path of a local PDF.
import chainlit as cl@cl.on_chat_startasync def main(): # Sending a pdf with the local file path elements = [ cl.Pdf(name="pdf1", display="inline", path="./pdf1.pdf", page=1) ] await cl.Message(content="Look at this local pdf!", elements=elements).send()
You must have the name of the pdf in the content of the message for the link to be created.
Copy
import chainlit as cl@cl.on_chat_startasync def main(): # Sending a pdf with the local file path elements = [ cl.Pdf(name="pdf1", display="side", path="./pdf1.pdf", page=1) ] # Reminder: The name of the pdf must be in the content of the message await cl.Message(content="Look at this local pdf1!", elements=elements).send()