Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions api-reference/elements/local-image.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ The `LocalImage` class is designed to create and handle local image elements to
### Usage with message scope

```python Code Example
from chainlit import LocalImage
import chainlit as cl

# Sending an image with the local file path
elements = [
LocalImage(name="image1", display="inline", path="./image1.jpg")
cl.LocalImage(name="image1", display="inline", path="./image1.jpg")
]

cl.Message(content="Look at this local image!", elements=elements).send()
Expand All @@ -45,15 +45,15 @@ cl.Message(content="Look at this local image!", elements=elements).send()
### Usage without scope

```python Code Example
from chainlit import LocalImage
import chainlit as cl

# Sending an image with the local file path
image1 = LocalImage(name="image1", display="inline", path="./image1.jpg")
image1 = cl.LocalImage(name="image1", display="inline", path="./image1.jpg")
image1.send()

# Sending an image with file content as bytes
with open("./image2.jpg", "rb") as f:
image_content = f.read()
image2 = LocalImage(name="image2", display="inline", content=image_content)
image2 = cl.LocalImage(name="image2", display="inline", content=image_content)
image2.send()
```
58 changes: 58 additions & 0 deletions api-reference/elements/pdf.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: "PDF viewer"
---

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.

### Attributes

<ParamField path="name" type="str">
The name of the PDF to be displayed in the UI.
</ParamField>

<ParamField path="display" type="ElementDisplay" optional>
Determines how the PDF element should be displayed in the UI. Choices are
"side" (default), "inline", or "page".
</ParamField>

<ParamField path="url" type="str">
The remote URL of the PDF file. Must provide url for a remote PDF (or either path or content for a local PDF).
</ParamField>

<ParamField path="path" type="str" optional>
The local file path of the PDF. Must provide either path or content for a local PDF (or url for a remote PDF).
</ParamField>

<ParamField path="content" type="bytes" optional>
The file content of the PDF in bytes format. Must provide either path or
content for a local PDF (or url for a remote PDF).
</ParamField>

### Usage with message scope

```python Code Example
import chainlit as cl

# Sending a pdf with the local file path
elements = [
cl.Pdf(name="pdf1", display="inline", path="./pdf1.pdf")
]

cl.Message(content="Look at this local pdf!", elements=elements).send()
```

### Usage without scope

```python Code Example
import chainlit as cl

# Sending a pdf with the remote url
pdf1 = cl.Pdf(name="pdf1", display="inline", url="https://example.com/example.pdf")
pdf1.send()

# Sending a pdf with file content as bytes
with open("./pdf2.pdf", "rb") as f:
pdf_content = f.read()
pdf2 = cl.Pdf(name="pdf2", display="inline", content=pdf_content)
pdf2.send()
```
1 change: 1 addition & 0 deletions mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"group": "Elements",
"pages": [
"api-reference/elements/local-image",
"api-reference/elements/pdf",
"api-reference/elements/remote-image",
"api-reference/elements/text"
]
Expand Down