MIT License

项目介绍

amjadraza/langchain-chainlit-docker-deployment-template 是一个托管在 GitHub 上的开源项目,主要使用 Dockerfile 编写,采用 MIT License 许可证,目前获得 52 个 Star、53 次 Fork。

仓库全名
amjadraza/langchain-chainlit-docker-deployment-template
开源许可证
MIT License
Star 数
52
Fork 数
53
未关闭 Issue
2

README 摘要

📖 LangChain-Chainlit-Docker-Deployment App Template 🔧 Features Basic Skeleton App configured with openai API A ChatBot using LangChain 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-streamlit-docker-template This repo contains an main.py file which has a template…

完整内容见 GitHub 原始 README 或本页 。

常见问题

langchain-chainlit-docker-deployment-template 用什么语言开发?

主要使用 Dockerfile 编写,采用 MIT License 许可证,目前有 52 个 Star。

langchain-chainlit-docker-deployment-template 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 langchain-chainlit-docker-deployment-template 的源码?

可以直接克隆仓库:git clone https://github.com/amjadraza/langchain-chainlit-docker-deployment-template.git,默认分支为 main;安装与运行步骤见仓库 README。

langchain-chainlit-docker-deployment-template 最近还在维护吗?

仓库最近一次更新为 2024年5月2日,当前有 2 个未关闭 Issue;Star 数为 52,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

A template to run Lanchain Powered App using Chainlit Front UI

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
159
价值分
47
活跃状态
活跃

语言占比

Dockerfile
Python

README

📖 LangChain-Chainlit-Docker-Deployment App Template

UI

🔧 Features

  • Basic Skeleton App configured with openai API
  • A ChatBot using LangChain 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-streamlit-docker-template

This repo contains an main.py file which has a template for a chatbot 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/langchain-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 langchain-chainlit-chat-app:latest

To generate Image with DOCKER_BUILDKIT, follow below command

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

  1. Run the docker container directly

docker run -d --name langchain-chainlit-chat-app -p 8000:8000 langchain-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://langchain-chat-app-ex6cbrefpq-ts.a.run.app/

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]

  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 langchain-app-cr \
    --display-name="langchain-app-cr"

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

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

gcloud projects add-iam-policy-binding langchain-chat \
    --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/langchain-chat/clapp/langchain-chainlit-chat-app:latest

  1. Push Image to Google Artifact’s Registry

Create the repository with name clapp

gcloud artifacts repositories create clapp \
    --repository-format=docker \
    --location=australia-southeast1 \
    --description="A Langachain 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/langchain-chat/clapp/langchain-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 langchain-chat-app --image=australia-southeast1-docker.pkg.dev/langchain-chat/clapp/langchain-chainlit-chat-app:latest \
    --region=australia-southeast1 \
    --service-account=langchain-app-cr@langchain-chat.iam.gserviceaccount.com \
    --port=8000
  1. Test the App Yourself

You can try the app using below link

https://langchain-chat-app-ex6cbrefpq-ts.a.run.app/

Report Feedbacks

As langchain-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.

评论

暂无评论