Taiowaz / TianGong-AI-Chat

TianGong-AI-Chat

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TianGong Chat Docker Publish

Env Preparing

Using VSCode Dev Contariners

Tutorial

Python 3 -> Additional Options -> 3.11-bullseye -> ZSH Plugins (Last One) -> Trust @devcontainers-contrib -> Keep Defaults

Setup venv:

python3.11 -m venv .venv
source .venv/bin/activate

Install requirements:

pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install -r requirements.txt --upgrade

pip freeze > requirements_freeze.txt
sudo apt install python3.11-dev

sudo apt -y install libmagic-dev
sudo apt -y install poppler-utils
sudo apt -y install tesseract-ocr
sudo apt -y install libreoffice
sudo apt -y install pandoc

Install Cuda (optional):

sudo apt install nvidia-cuda-toolkit

Env Preparing in MacOS

Install Python 3.11

brew update
brew install python@3.11

Setup venv:

python3.11 -m venv .venv
source .venv/bin/activate

Install requirements:

pip install --upgrade pip
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install -r requirements.txt --upgrade
brew update
brew install libmagic
brew install poppler-qt5
# echo 'export PATH="/usr/local/opt/poppler-qt5/bin:$PATH"' >> ~/.zshrc
# export LDFLAGS="-L/usr/local/opt/poppler-qt5/lib"
# export CPPFLAGS="-I/usr/local/opt/poppler-qt5/include"
brew install tesseract
# brew install tesseract-lang
# brew cleanup tesseract-lang
brew install libreoffice
brew install pandoc

Start

export ui=tiangong-en

streamlit run Chat.py

Auto Build

The auto build will be triggered by pushing any tag named like release-v$version. For instance, push a tag named as v0.0.1 will build a docker image of 0.0.1 version.

#list existing tags
git tag
#creat a new tag
git tag v0.0.1
#push this tag to origin
git push origin v0.0.1

sphinx

sphinx-apidoc --force -o sphinx/source/ src/
sphinx-autobuild sphinx/source docs/

Docker Manually Build

docker build -t linancn/tiangong-ai-chat:v0.0.1 .
docker push linancn/tiangong-ai-chat:v0.0.1

Production Run

docker network create tiangongbridge

docker run --detach \
    --name nginx-proxy \
    --restart=always \
    --publish 80:80 \
    --publish 443:443 \
    --volume certs:/etc/nginx/certs \
    --volume vhost:/etc/nginx/vhost.d \
    --volume html:/usr/share/nginx/html \
    --volume /var/run/docker.sock:/tmp/docker.sock:ro \
    --network=tiangongbridge \
    --network-alias=nginx-proxy \
    nginxproxy/nginx-proxy:latest

docker run --detach \
    --name nginx-proxy-acme \
    --restart=always \
    --volumes-from nginx-proxy \
    --volume /var/run/docker.sock:/var/run/docker.sock:ro \
    --volume acme:/etc/acme.sh \
    --network=tiangongbridge \
    --network-alias=nginx-proxy-acme \
    nginxproxy/acme-companion:latest

docker run --detach \
    --name tiangong-ai-chat \
    --restart=always \
    --expose 8501 \
    --net=tiangongbridge \
    --env ui=tiangong-en \
    --env VIRTUAL_HOST=YourURL \
    --env VIRTUAL_PORT=8501 \
    --env LETSENCRYPT_HOST=YourURL \
    --env LETSENCRYPT_EMAIL=YourEmail \
    linancn/tiangong-ai-chat:latest

docker cp .streamlit/secrets.toml tiangong-ai-chat:/app/.streamlit/secrets.toml

Nginx config

default file location: /etc/nginx/sites-enabled/default

sudo apt update
sudo apt install nginx
sudo nginx
sudo nginx -s reload
sudo nginx -s stop

To Do

DDG empty results bug

About

TianGong-AI-Chat

License:MIT License


Languages

Language:Python 97.4%Language:HTML 1.0%Language:Dockerfile 0.6%Language:Batchfile 0.5%Language:Makefile 0.4%Language:CSS 0.0%