Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Chainlit docker-based example #235

Merged
merged 3 commits into from
Jun 10, 2024
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
5 changes: 5 additions & 0 deletions doc/apps/chainlit.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ To deploy a Chainlit application in Ploomber Cloud you need:
- Your application file (`app.py`)
- A dependencies file (`requirements.txt`)

```{note}
By default applications run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.
[Here](https://github.com/ploomber/doc/tree/main/examples/chainlit/docker-based) is a sample Docker-based `Chainlit` application.
```

## Testing locally

To test your app, you can use this command:
Expand Down
5 changes: 4 additions & 1 deletion doc/apps/dash.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ To deploy a [Dash](https://dash.plotly.com/) application you need a [Ploomber Cl
1. Your application file (`app.py`)
2. A dependencies file (`requirements.txt`)

Note that the application will run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.

```{note}
By default applications run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.
[Here](https://github.com/ploomber/doc/tree/main/examples/dash/docker-based) is a sample Docker-based `Dash` application.
```

## Required files

Expand Down
5 changes: 4 additions & 1 deletion doc/apps/panel.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ Once you have an account, you need at least two files:
1. Your application file (`app.py`)
2. A dependencies file (`requirements.txt`)

Note that the application will run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.

```{note}
By default applications run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.
[Here](https://github.com/ploomber/doc/tree/main/examples/panel/docker-based) is a sample Docker-based `Panel` application.
```


## Application file
Expand Down
5 changes: 4 additions & 1 deletion doc/apps/solara.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ To deploy a Solara app you need at least two files zipped up:
1. Your application file (`app.py`)
2. A dependencies file (`requirements.txt`)

Note that the application will run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.

```{note}
By default applications run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.
[Here](https://github.com/ploomber/doc/tree/main/examples/solara/docker-based) is a sample Docker-based `Solara` application.
```


```{note}
Expand Down
4 changes: 3 additions & 1 deletion doc/apps/streamlit.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ To deploy a Streamlit app you need at least two files:
1. Your application file (`app.py`)
2. A dependencies file (`requirements.txt`)

Note that the application will run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.
```{note}
By default applications run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.
[Here](https://github.com/ploomber/doc/tree/main/examples/streamlit/docker-based) is a sample Docker-based `Streamlit` application.
```

## Application file

Expand Down
5 changes: 4 additions & 1 deletion doc/apps/voila.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ To deploy an application you need two files:

For information on how to write Voilà applications, [please check the documentation](https://voila.readthedocs.io/en/stable/).

Note that the application will run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.

```{note}
By default applications run with Python 3.11. Refer to this [section](../faq/faq.md#customize-deployment) for customized deployments.
[Here](https://github.com/ploomber/doc/tree/main/examples/voila/docker-based) is a sample Docker-based `Voila` application.
```

## Dependencies

Expand Down
7 changes: 0 additions & 7 deletions examples/chainlit/app-with-auth0/Dockerfile

This file was deleted.

7 changes: 0 additions & 7 deletions examples/chainlit/basic-app/Dockerfile

This file was deleted.

11 changes: 11 additions & 0 deletions examples/chainlit/docker-based/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.11-slim-bookworm

WORKDIR /srv

COPY requirements.txt /srv/
COPY . /srv

RUN pip install chainlit --no-cache-dir
RUN pip install -r requirements.txt --no-cache-dir

ENTRYPOINT ["chainlit", "run", "app.py", "--host=0.0.0.0", "--port=80", "--headless"]
5 changes: 5 additions & 0 deletions examples/chainlit/docker-based/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Basic app

A basic Chainlit application to get started.

![](screenshot.webp)
10 changes: 10 additions & 0 deletions examples/chainlit/docker-based/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import chainlit as cl


@cl.on_message # this function will be called every time a user inputs a message in the UI
async def main(message: str):
# this is an intermediate step
await cl.Message(author="Tool 1", content=f"Response from tool1").send()

# send back the final answer
await cl.Message(content=f"This is a Docker-based Chainlit app.").send()
Binary file added examples/chainlit/docker-based/app.zip
Binary file not shown.
1 change: 1 addition & 0 deletions examples/chainlit/docker-based/chainlit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This app is hosted in [Ploomber Cloud!](https://ploomber.io/)
1 change: 1 addition & 0 deletions examples/chainlit/docker-based/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chainlit
Loading