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

Update Chainlit examples #229

Merged
merged 3 commits into from
May 26, 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
74 changes: 52 additions & 22 deletions doc/apps/chainlit.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,76 @@ Ploomber Cloud is a great platform to host your Chainlit apps, even [Chainlit re

To deploy a Chainlit application in Ploomber Cloud you need:

- A [Ploomber Cloud](https://platform.ploomber.io/register?utm_source=chainlit&utm_medium=documentation) account
- A `Dockerfile`
- Your code
- A [Ploomber Cloud](https://platform.ploomber.io/register?utm_source=flask&utm_medium=documentation) account
- Your application file (`app.py`)
- A dependencies file (`requirements.txt`)

## `Dockerfile`
## Testing locally

To test your app, you can use this command:

```sh
pip install -r requirements.txt
chainlit run app.py --host=0.0.0.0 --port=5000 --headless
```

Now, open [http://0.0.0.0:5000/](http://0.0.0.0:5000/) to see your app.

## Deploy

`````{tab-set}

````{tab-item} Web
__Deploy from the menu__

Once you have all your files, create a zip file.

To deploy a Chainlit app from the deployment menu, follow these instructions:

You need to provide a `Dockerfile`, you can use this [template](https://github.com/ploomber/doc/blob/main/examples/chainlit/basic-app/Dockerfile) to get started. The template contains the minimal steps needed for a deployment but you need to modify so it installs any required dependencies and copies your code into the Docker image.
![](../static/chainlit.png)
````

```Dockerfile
FROM python:3.11
````{tab-item} Command-line
__Try an example__

COPY app.py app.py
RUN pip install chainlit
To download and deploy an example Chainlit application start by installing Ploomber Cloud and setting your API key:

# do not change the arguments
ENTRYPOINT ["chainlit", "run", "app.py", "--host=0.0.0.0", "--port=80", "--headless"]
```sh
pip install ploomber-cloud
ploomber-cloud key YOUR-KEY
```

## Testing locally
```{tip}
If you don't have an API key yet, follow the [instructions here.](../quickstart/apikey.md)
```

To test your app, you can use `docker` locally:
Now, download an example. It will prompt you for a location to download the app. To download in the current directory, just press enter.

```sh
# build the docker image
docker build . -t chainlit
ploomber-cloud examples chainlit/basic-app
```

# run it
docker run -p 5000:80 chainlit
```{note}
A full list of Chainlit example apps is available [here.](https://github.com/ploomber/doc/tree/main/examples/chainlit)
```

Now, open [http://0.0.0.0:5000/](http://0.0.0.0:5000/) to see your app.
You should see a confirmation with instructions on deploying your app. Now, navigate to your application:

```sh
cd location-you-entered/basic-app
```

## Deploy
__Deploy from the CLI__

Once you have all your files, create a zip file.
Initialize and deploy your app with:

To deploy a Chainlit app from the deployment menu, follow these instructions:
```sh
ploomber-cloud init
ploomber-cloud deploy --watch
```

![](../static/docker.png)
````
`````


```{tip}
Expand Down
Binary file added doc/static/chainlit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/chainlit/app-with-auth0/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chainlit
Binary file modified examples/chainlit/basic-app/app.zip
Binary file not shown.
1 change: 1 addition & 0 deletions examples/chainlit/basic-app/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chainlit
7 changes: 0 additions & 7 deletions examples/chainlit/chainlit-with-password/Dockerfile

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chainlit
8 changes: 0 additions & 8 deletions examples/chainlit/chat-with-pdf/Dockerfile

This file was deleted.

9 changes: 0 additions & 9 deletions examples/chainlit/private-chatgpt/Dockerfile

This file was deleted.