Giter Site home page Giter Site logo

amjadraza / pandasai-chainlit-docker-deployment-template Goto Github PK

View Code? Open in Web Editor NEW
15.0 1.0 6.0 681 KB

A template app to build & deploy PandasAI app to make your csv files conversational

Home Page: https://pandasai-chat-app-dpy4wfgkcq-ts.a.run.app/

License: MIT License

Dockerfile 12.81% Python 87.19%
chainlit openai pandasai

pandasai-chainlit-docker-deployment-template's Introduction

📖 PandasAI-Chainlit-Docker-Deployment App Template

UI

🔧 Features

  • Basic Skeleton App configured with openai API
  • A ChatBot using PandasAI and Chainlit
  • Docker Support with Optimisation Cache etc
  • Deployment on Google Cloud App Engine
  • Deployment on Google Cloud using Cloud Run

Reference repository: https://github.com/amjadraza/langchain-chainlit-docker-template

This repo contains an main.py file which has a template for a chatbot talking to CSV implementation.

Adding your chain

To add your chain, you need to change the load_chain function in main.py. Depending on the type of your chain, you may also need to change the inputs/outputs that occur later on.

💻 Running Locally

  1. Clone the repository📂
git clone https://github.com/amjadraza/pandasai-chainlit-docker-deployment-template
  1. Install dependencies with Poetry and activate virtual environment🔨
poetry install
poetry shell
  1. Run the Chainlit server🚀
chainlit run demo_app/main.py

Run App using Docker

This project includes Dockerfile to run the app in Docker container. In order to optimise the Docker Image size and building time with cache techniques, I have follow tricks in below Article https://medium.com/@albertazzir/blazing-fast-python-docker-builds-with-poetry-a78a66f5aed0

Build the docker container

docker build . -t pandasai-chainlit-chat-app:latest

To generate Image with DOCKER_BUILDKIT, follow below command

DOCKER_BUILDKIT=1 docker build --target=runtime . -t pandasai-chainlit-chat-app:latest

  1. Run the docker container directly

docker run -d --name pandasai-chainlit-chat-app -p 8000:8000 pandasai-chainlit-chat-app

  1. Run the docker container using docker-compose (Recommended)

docker-compose up

Deploy App on Google App Engine

This app can be deployed on Google App Engine following below steps.

Prerequisites

Follow below guide on basic Instructions. How to deploy Streamlit apps to Google App Engine

We added below tow configurations files

  1. app.yaml: A Configuration file for gcloud
  2. .gcloudignore : Configure the file to ignore file / folders to be uploaded

I have adopted Dockerfile to deploy the app on GCP APP Engine.

  1. Initialise & Configure the App

gcloud app create --project=[YOUR_PROJECT_ID]

  1. Deploy the App using

gcloud app deploy

  1. Access the App using

https://pandasai-chat-app-dpy4wfgkcq-ts.a.run.app/

Deploy App on Google Cloud using Cloud Run (RECOMMENDED)

This app can be deployed on Google Cloud using Cloud Run following below steps.

Prerequisites

Follow below guide on basic Instructions. How to deploy Streamlit apps to Google App Engine

We added below tow configurations files

  1. cloudbuild.yaml: A Configuration file for gcloud
  2. .gcloudignore : Configure the file to ignore file / folders to be uploaded

we are going to use Dockerfile to deploy the app using Google Cloud Run.

  1. Initialise & Configure the Google Project using Command Prompt

gcloud app create --project=[YOUR_PROJECT_ID]

or set the project

gcloud config set pandasai-app

Set the Region if not done before

gcloud config set compute/region australia-southeast1

  1. Enable Services for the Project
gcloud services enable cloudbuild.googleapis.com
gcloud services enable run.googleapis.com
  1. Create Service Account
gcloud iam service-accounts create pandasai-app-cr \
    --display-name="pandasai-app-cr"

gcloud projects add-iam-policy-binding pandasai-app \
    --member="serviceAccount:[email protected]" \
    --role="roles/run.invoker"

gcloud projects add-iam-policy-binding pandasai-app \
    --member="serviceAccount:[email protected]" \
    --role="roles/serviceusage.serviceUsageConsumer"

gcloud projects add-iam-policy-binding pandasai-app \
    --member="serviceAccount:[email protected]" \
    --role="roles/run.admin"
  1. Generate the Docker

DOCKER_BUILDKIT=1 docker build --target=runtime . -t australia-southeast1-docker.pkg.dev/pandasai-app/pai-app/pandasai-chainlit-chat-app:latest

  1. Push Image to Google Artifact's Registry

Create the repository with name pai-app

gcloud artifacts repositories create pai-app \
    --repository-format=docker \
    --location=australia-southeast1 \
    --description="A PandasAI Chainlit App" \
    --async

Configure-docker

gcloud auth configure-docker australia-southeast1-docker.pkg.dev

In order to push the docker-image to Artifact registry, first create app in the region of choice.

Check the artifacts locations

gcloud artifacts locations list

Once ready, let us push the image to location

docker push australia-southeast1-docker.pkg.dev/pandasai-app/pai-app/pandasai-chainlit-chat-app:latest

  1. Deploy using Cloud Run

Once image is pushed to Google Cloud Artifacts Registry. Let us deploy the image.

gcloud run deploy pandasai-chat-app --image=australia-southeast1-docker.pkg.dev/pandasai-app/pai-app/pandasai-chainlit-chat-app:latest \
    --region=australia-southeast1 \
    --service-account=pandasai-app-cr@pandasai-app.iam.gserviceaccount.com \
    --port=8000
  1. Test the App Yourself

You can try the app using below link

https://pandasai-chat-app-dpy4wfgkcq-ts.a.run.app/

Report Feedbacks

As pandasai-chainlit-docker-deployment-template is a template project with minimal example. Report issues if you face any.

DISCLAIMER

This is a template App, when using with openai_api key, you will be charged a nominal fee depending on number of prompts etc.

pandasai-chainlit-docker-deployment-template's People

Contributors

amjadraza avatar hwchase17 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.