mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-07-19 18:40:00 +00:00
feat(build): Support docker install
This commit is contained in:
parent
ee1ac0df8e
commit
455cdd1612
@ -5,6 +5,8 @@ models/
|
||||
plugins/
|
||||
pilot/data
|
||||
pilot/message
|
||||
pilot/meta_data/alembic/versions
|
||||
pilot/meta_data/dbgpt.db
|
||||
logs/
|
||||
venv/
|
||||
.venv/
|
||||
|
48
.github/workflows/docker-image-publish-openai.yml
vendored
Normal file
48
.github/workflows/docker-image-publish-openai.yml
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
name: Build and Push OpenAI Docker Image
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build-image:
|
||||
runs-on: ubuntu-latest
|
||||
# run unless event type is pull_request
|
||||
if: github.event_name != 'pull_request'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: free disk space
|
||||
run: |
|
||||
sudo swapoff -a
|
||||
sudo rm -f /swapfile
|
||||
sudo apt clean
|
||||
# Only delete Docker images when they exist
|
||||
if [ ! -z "$(docker image ls -aq)" ]; then
|
||||
docker rmi $(docker image ls -aq)
|
||||
fi
|
||||
df -h
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ./docker/base/Dockerfile
|
||||
build-args: |
|
||||
BASE_IMAGE=ubuntu:22.04
|
||||
EXTRAS=base,proxy_openai,rag,graph_rag,storage_chromadb,dbgpts,proxy_ollama,proxy_zhipuai,proxy_anthropic,proxy_qianfan,proxy_tongyi
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
push: true
|
||||
tags: eosphorosai/dbgpt-openai:${{ github.ref_name }},eosphorosai/dbgpt-openai:latest
|
45
configs/dbgpt-proxy-siliconflow-mysql.toml
Normal file
45
configs/dbgpt-proxy-siliconflow-mysql.toml
Normal file
@ -0,0 +1,45 @@
|
||||
[system]
|
||||
# Load language from environment variable(It is set by the hook)
|
||||
language = "${env:DBGPT_LANG:-zh}"
|
||||
api_keys = []
|
||||
encrypt_key = "your_secret_key"
|
||||
|
||||
# Server Configurations
|
||||
[service.web]
|
||||
host = "0.0.0.0"
|
||||
port = 5670
|
||||
|
||||
[service.web.database]
|
||||
type = "mysql"
|
||||
host = "${env:MYSQL_HOST:-127.0.0.1}"
|
||||
port = "${env:MYSQL_PORT:-3306}"
|
||||
database = "${env:MYSQL_DATABASE:-dbgpt}"
|
||||
user = "${env:MYSQL_USER:-root}"
|
||||
password ="${env:MYSQL_PASSWORD:-aa123456}"
|
||||
|
||||
[service.model.worker]
|
||||
host = "127.0.0.1"
|
||||
|
||||
[rag.storage]
|
||||
[rag.storage.vector]
|
||||
type = "Chroma"
|
||||
persist_path = "pilot/data"
|
||||
|
||||
# Model Configurations
|
||||
[models]
|
||||
[[models.llms]]
|
||||
name = "Qwen/Qwen2.5-Coder-32B-Instruct"
|
||||
provider = "proxy/siliconflow"
|
||||
api_key = "${env:SILICONFLOW_API_KEY}"
|
||||
|
||||
[[models.embeddings]]
|
||||
name = "BAAI/bge-large-zh-v1.5"
|
||||
provider = "proxy/openai"
|
||||
api_url = "https://api.siliconflow.cn/v1/embeddings"
|
||||
api_key = "${env:SILICONFLOW_API_KEY}"
|
||||
|
||||
[[models.rerankers]]
|
||||
type = "reranker"
|
||||
name = "BAAI/bge-reranker-v2-m3"
|
||||
provider = "proxy/siliconflow"
|
||||
api_key = "${env:SILICONFLOW_API_KEY}"
|
@ -1,5 +1,5 @@
|
||||
version: '3.10'
|
||||
|
||||
# To run current docker compose file, you should prepare the silliconflow api key in your environment.
|
||||
# SILICONFLOW_API_KEY=${SILICONFLOW_API_KEY} docker compose up -d
|
||||
services:
|
||||
db:
|
||||
image: mysql/mysql-server
|
||||
@ -18,23 +18,24 @@ services:
|
||||
networks:
|
||||
- dbgptnet
|
||||
webserver:
|
||||
image: eosphorosai/dbgpt:latest
|
||||
command: python3 dbgpt/app/dbgpt_server.py
|
||||
image: eosphorosai/dbgpt-openai:latest
|
||||
command: dbgpt start webserver --config /app/configs/dbgpt-proxy-siliconflow-mysql.toml
|
||||
environment:
|
||||
- LOCAL_DB_HOST=db
|
||||
- LOCAL_DB_PASSWORD=aa123456
|
||||
- ALLOWLISTED_PLUGINS=db_dashboard
|
||||
- LLM_MODEL=glm-4-9b-chat
|
||||
depends_on:
|
||||
- db
|
||||
- SILICONFLOW_API_KEY=${SILICONFLOW_API_KEY}
|
||||
- MYSQL_PASSWORD=aa123456
|
||||
- MYSQL_HOST=db
|
||||
- MYSQL_PORT=3306
|
||||
- MYSQL_DATABASE=dbgpt
|
||||
- MYSQL_USER=root
|
||||
volumes:
|
||||
- ./configs:/app/configs
|
||||
- /data:/data
|
||||
# Please modify it to your own model directory
|
||||
# May be you can mount your models to container
|
||||
- /data/models:/app/models
|
||||
- dbgpt-data:/app/pilot/data
|
||||
- dbgpt-message:/app/pilot/message
|
||||
env_file:
|
||||
- .env.template
|
||||
depends_on:
|
||||
- db
|
||||
ports:
|
||||
- 5670:5670/tcp
|
||||
# webserver may be failed, it must wait all sqls in /docker-entrypoint-initdb.d execute finish.
|
||||
@ -42,16 +43,11 @@ services:
|
||||
networks:
|
||||
- dbgptnet
|
||||
ipc: host
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
capabilities: [gpu]
|
||||
volumes:
|
||||
dbgpt-myql-db:
|
||||
dbgpt-data:
|
||||
dbgpt-message:
|
||||
dbgpt-alembic-versions:
|
||||
networks:
|
||||
dbgptnet:
|
||||
driver: bridge
|
||||
|
@ -1,18 +1,32 @@
|
||||
ARG BASE_IMAGE="nvidia/cuda:12.1.0-devel-ubuntu22.04"
|
||||
ARG BASE_IMAGE="nvidia/cuda:12.4.0-devel-ubuntu22.04"
|
||||
# Add parameter to control whether to use Tsinghua Ubuntu mirror
|
||||
ARG USE_TSINGHUA_UBUNTU="false"
|
||||
|
||||
FROM ${BASE_IMAGE} as builder
|
||||
ARG BASE_IMAGE
|
||||
ARG PYTHON_VERSION=3.10
|
||||
ARG PYPI_MIRROR=https://pypi.org/simple
|
||||
ARG EXTRAS="proxy_openai,rag,storage_chromadb,quant_bnb"
|
||||
ARG PYTHON_VERSION=3.11
|
||||
# Use Tsinghua PyPI mirror, It's faster in most countries
|
||||
ARG PIP_INDEX_URL="https://pypi.tuna.tsinghua.edu.cn/simple"
|
||||
ARG EXTRAS="base,proxy_openai,rag,storage_chromadb,cuda121,hf,quant_bnb,dbgpts"
|
||||
ARG VERSION=latest
|
||||
|
||||
ARG USE_TSINGHUA_UBUNTU
|
||||
ARG CMAKE_ARGS
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
LANG=C.UTF-8 \
|
||||
LC_ALL=C.UTF-8 \
|
||||
PIP_INDEX_URL=${PYPI_MIRROR}
|
||||
PIP_INDEX_URL=${PIP_INDEX_URL} \
|
||||
CMAKE_ARGS=${CMAKE_ARGS}
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
# Configure apt sources based on the USE_TSINGHUA_UBUNTU parameter
|
||||
RUN if [ "$USE_TSINGHUA_UBUNTU" = "true" ]; then \
|
||||
sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
|
||||
sed -i 's/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list; \
|
||||
fi && \
|
||||
apt-get update && apt-get install -y --no-install-recommends gnupg ca-certificates apt-transport-https && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
apt-get update && apt-get install -y \
|
||||
python${PYTHON_VERSION} \
|
||||
python${PYTHON_VERSION}-venv \
|
||||
python3-pip \
|
||||
@ -33,73 +47,58 @@ RUN apt-get update && apt-get install -y \
|
||||
&& pipx install uv --global
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Create a virtual environment
|
||||
ENV VIRTUAL_ENV=/app/.venv
|
||||
RUN python${PYTHON_VERSION} -m venv $VIRTUAL_ENV
|
||||
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||
|
||||
COPY pyproject.toml README.md uv.lock ./
|
||||
COPY packages /app/packages
|
||||
|
||||
# Install dependencies with uv and install all local packages
|
||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
extras=$(echo $EXTRAS | tr ',' '\n' | while read extra; do echo "--extra $extra"; done | tr '\n' ' ') && \
|
||||
uv sync --frozen --all-packages --no-dev $extras && \
|
||||
# Install local packages, pay attention to the installation order
|
||||
cd /app/packages/dbgpt-accelerator && pip install -e . && \
|
||||
cd /app/packages/dbgpt-core && pip install -e . && \
|
||||
cd /app/packages/dbgpt-ext && pip install -e . && \
|
||||
cd /app/packages/dbgpt-client && pip install -e . && \
|
||||
cd /app/packages/dbgpt-serve && pip install -e . && \
|
||||
cd /app/packages/dbgpt-app && pip install -e . && \
|
||||
# Verify installation
|
||||
python -c "import dbgpt; print(dbgpt.__version__)"
|
||||
|
||||
ARG BUILD_LOCAL_CODE="false"
|
||||
ARG LANGUAGE="en"
|
||||
ARG PIP_INDEX_URL="https://pypi.org/simple"
|
||||
ARG PIP_INDEX_URL="https://pypi.tuna.tsinghua.edu.cn/simple"
|
||||
ENV PIP_INDEX_URL=$PIP_INDEX_URL
|
||||
ARG DB_GPT_INSTALL_MODEL="default"
|
||||
ENV DB_GPT_INSTALL_MODEL=$DB_GPT_INSTALL_MODEL
|
||||
|
||||
|
||||
FROM ${BASE_IMAGE}
|
||||
|
||||
ARG PYTHON_VERSION=3.10
|
||||
ARG PYTHON_VERSION=3.11
|
||||
ARG VERSION=latest
|
||||
|
||||
ARG USE_TSINGHUA_UBUNTU
|
||||
# Set environment variables
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
LANG=C.UTF-8 \
|
||||
LC_ALL=C.UTF-8
|
||||
# Set PYTHONPATH
|
||||
|
||||
# Version label
|
||||
LABEL version=${VERSION}
|
||||
|
||||
# Install runtime dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
# Configure apt sources based on the USE_TSINGHUA_UBUNTU parameter
|
||||
RUN if [ "$USE_TSINGHUA_UBUNTU" = "true" ]; then \
|
||||
sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
|
||||
sed -i 's/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list; \
|
||||
fi && \
|
||||
apt-get update && apt-get install -y --no-install-recommends gnupg ca-certificates apt-transport-https && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
apt-get update && apt-get install -y \
|
||||
python${PYTHON_VERSION} \
|
||||
python${PYTHON_VERSION}-venv \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the virtual environment from the previous stage
|
||||
# Use antoher name to avoid conflict when mounting user's local .venv
|
||||
ENV FINAL_VENV_NAME="/opt/.uv.venv"
|
||||
COPY --from=builder /app/.venv ${FINAL_VENV_NAME}
|
||||
COPY . .
|
||||
|
||||
# Fix the shebang of the dbgpt script
|
||||
RUN sed -i "s|^#\!/app/\.venv/bin/python[0-9.]*|#!/${FINAL_VENV_NAME}/bin/python${PYTHON_VERSION}|" /${FINAL_VENV_NAME}/bin/dbgpt
|
||||
RUN sed -i "s|^#\!/app/\.venv/bin/python[0-9.]*|#!/${FINAL_VENV_NAME}/bin/python${PYTHON_VERSION}|" /${FINAL_VENV_NAME}/bin/pip
|
||||
|
||||
ENV PATH="${FINAL_VENV_NAME}/bin:$PATH" \
|
||||
VIRTUAL_ENV="${FINAL_VENV_NAME}"
|
||||
# PYTHONPATH="/app/packages/dbgpt/src:/app/packages/dbgpt-core/src:/app/packages/dbgpt-app/src:/app/packages/dbgpt-serve/src:/app/packages/dbgpt-client/src:/app/packages/dbgpt-ext/src:/app/packages/dbgpt-accelerator/src"
|
||||
|
||||
# Default command
|
||||
CMD ["dbgpt", "start", "webserver", "--config", "configs/dbgpt-siliconflow.toml"]
|
||||
CMD ["dbgpt", "start", "webserver", "--config", "configs/dbgpt-proxy-siliconflow.toml"]
|
@ -4,41 +4,107 @@ SCRIPT_LOCATION=$0
|
||||
cd "$(dirname "$SCRIPT_LOCATION")"
|
||||
WORK_DIR=$(pwd)
|
||||
|
||||
BASE_IMAGE_DEFAULT="nvidia/cuda:12.1.0-devel-ubuntu22.04"
|
||||
BASE_IMAGE_DEFAULT_CPU="ubuntu:22.04"
|
||||
# Base image definitions
|
||||
CUDA_BASE_IMAGE="nvidia/cuda:12.4.0-devel-ubuntu22.04"
|
||||
CPU_BASE_IMAGE="ubuntu:22.04"
|
||||
|
||||
BASE_IMAGE=$BASE_IMAGE_DEFAULT
|
||||
# Define installation mode configurations: base_image, extras
|
||||
declare -A INSTALL_MODES
|
||||
|
||||
# Common mode configurations - Base configuration shared by modes using CUDA image
|
||||
DEFAULT_PROXY_EXTRAS="base,proxy_openai,rag,graph_rag,storage_chromadb,dbgpts,proxy_ollama,proxy_zhipuai,proxy_anthropic,proxy_qianfan,proxy_tongyi"
|
||||
DEFAULT_CUDA_EXTRAS="${DEFAULT_PROXY_EXTRAS},cuda121,hf,quant_bnb,flash_attn,quant_awq"
|
||||
|
||||
# Define each installation mode
|
||||
# Default mode configuration
|
||||
INSTALL_MODES["default,base_image"]=$CUDA_BASE_IMAGE
|
||||
INSTALL_MODES["default,extras"]=$DEFAULT_CUDA_EXTRAS
|
||||
INSTALL_MODES["default,env_vars"]=""
|
||||
|
||||
# OpenAI mode configuration - The only mode using CPU image
|
||||
INSTALL_MODES["openai,base_image"]=$CPU_BASE_IMAGE
|
||||
INSTALL_MODES["openai,extras"]="${DEFAULT_PROXY_EXTRAS}"
|
||||
INSTALL_MODES["openai,env_vars"]=""
|
||||
|
||||
# vllm mode configuration
|
||||
INSTALL_MODES["vllm,base_image"]=$CUDA_BASE_IMAGE
|
||||
INSTALL_MODES["vllm,extras"]="$DEFAULT_CUDA_EXTRAS,vllm"
|
||||
INSTALL_MODES["vllm,env_vars"]=""
|
||||
|
||||
# llama-cpp mode configuration
|
||||
INSTALL_MODES["llama-cpp,base_image"]=$CUDA_BASE_IMAGE
|
||||
INSTALL_MODES["llama-cpp,extras"]="$DEFAULT_CUDA_EXTRAS,llama_cpp,llama_cpp_server"
|
||||
INSTALL_MODES["llama-cpp,env_vars"]="CMAKE_ARGS=\"-DGGML_CUDA=ON\""
|
||||
|
||||
# Full functionality mode
|
||||
INSTALL_MODES["full,base_image"]=$CUDA_BASE_IMAGE
|
||||
INSTALL_MODES["full,extras"]="$DEFAULT_CUDA_EXTRAS,vllm,llama-cpp,llama_cpp_server"
|
||||
INSTALL_MODES["full,env_vars"]="CMAKE_ARGS=\"-DGGML_CUDA=ON\""
|
||||
|
||||
# Default value settings
|
||||
BASE_IMAGE=$CUDA_BASE_IMAGE
|
||||
IMAGE_NAME="eosphorosai/dbgpt"
|
||||
IMAGE_NAME_ARGS=""
|
||||
|
||||
# zh: https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
PIP_INDEX_URL="https://pypi.org/simple"
|
||||
# en or zh
|
||||
PIP_INDEX_URL="https://pypi.tuna.tsinghua.edu.cn/simple"
|
||||
LANGUAGE="en"
|
||||
BUILD_LOCAL_CODE="true"
|
||||
LOAD_EXAMPLES="true"
|
||||
BUILD_NETWORK=""
|
||||
DB_GPT_INSTALL_MODEL="default"
|
||||
DEFAULT_EXTRAS="proxy_openai,rag,storage_chromadb,quant_bnb"
|
||||
DB_GPT_INSTALL_MODE="default"
|
||||
EXTRAS=""
|
||||
ADDITIONAL_EXTRAS=""
|
||||
DOCKERFILE="Dockerfile"
|
||||
IMAGE_NAME_SUFFIX=""
|
||||
USE_TSINGHUA_UBUNTU="true"
|
||||
PYTHON_VERSION="3.11" # Minimum supported Python version: 3.10
|
||||
BUILD_ENV_VARS=""
|
||||
ADDITIONAL_ENV_VARS=""
|
||||
|
||||
usage () {
|
||||
echo "USAGE: $0 [--base-image nvidia/cuda:12.1.0-devel-ubuntu22.04] [--image-name db-gpt]"
|
||||
echo "USAGE: $0 [--base-image nvidia/cuda:12.1.0-devel-ubuntu22.04] [--image-name ${BASE_IMAGE}]"
|
||||
echo " [-b|--base-image base image name] Base image name"
|
||||
echo " [-n|--image-name image name] Current image name, default: db-gpt"
|
||||
echo " [-n|--image-name image name] Current image name, default: ${IMAGE_NAME}"
|
||||
echo " [--image-name-suffix image name suffix] Image name suffix"
|
||||
echo " [-i|--pip-index-url pip index url] Pip index url, default: https://pypi.org/simple"
|
||||
echo " [-i|--pip-index-url pip index url] Pip index url, default: ${PIP_INDEX_URL}"
|
||||
echo " [--language en or zh] You language, default: en"
|
||||
echo " [--build-local-code true or false] Whether to use the local project code to package the image, default: true"
|
||||
echo " [--load-examples true or false] Whether to load examples to default database default: true"
|
||||
echo " [--network network name] The network of docker build"
|
||||
echo " [--install-mode mode name] Installation mode name, default: default, If you completely use openai's service, you can set the mode name to 'openai'"
|
||||
echo " [-f|--dockerfile dockerfile] Dockerfile name, default: Dockerfile"
|
||||
echo " [--install-mode mode name] Installation mode name, default: default"
|
||||
echo " Available modes: default, openai, vllm, llama-cpp, full"
|
||||
echo " [--extras extra packages] Comma-separated list of extra packages to install, overrides the default for the install mode"
|
||||
echo " [--add-extras additional packages] Comma-separated list of additional extra packages to append to the default extras"
|
||||
echo " [--env-vars \"ENV_VAR1=value1 ENV_VAR2=value2\"] Environment variables for build, overrides the default for the install mode"
|
||||
echo " [--add-env-vars \"ENV_VAR1=value1 ENV_VAR2=value2\"] Additional environment variables to append to the default env vars"
|
||||
echo " [--use-tsinghua-ubuntu true or false] Whether to use Tsinghua Ubuntu mirror, default: true"
|
||||
echo " [--python-version version] Python version to use, default: ${PYTHON_VERSION}"
|
||||
echo " [-f|--dockerfile dockerfile] Dockerfile name, default: ${DOCKERFILE}"
|
||||
echo " [--list-modes] List all available install modes with their configurations"
|
||||
echo " [-h|--help] Usage message"
|
||||
}
|
||||
|
||||
list_modes() {
|
||||
echo "Available installation modes:"
|
||||
echo "--------------------------"
|
||||
# Get unique mode names
|
||||
local modes=()
|
||||
for key in "${!INSTALL_MODES[@]}"; do
|
||||
local mode_name="${key%%,*}"
|
||||
if [[ ! " ${modes[@]} " =~ " ${mode_name} " ]]; then
|
||||
modes+=("$mode_name")
|
||||
fi
|
||||
done
|
||||
|
||||
# Print each mode's configuration
|
||||
for mode in "${modes[@]}"; do
|
||||
echo "Mode: $mode"
|
||||
echo " Base image: ${INSTALL_MODES["$mode,base_image"]}"
|
||||
echo " Extras: ${INSTALL_MODES["$mode,extras"]}"
|
||||
if [ -n "${INSTALL_MODES["$mode,env_vars"]}" ]; then
|
||||
echo " Environment Variables: ${INSTALL_MODES["$mode,env_vars"]}"
|
||||
fi
|
||||
echo "--------------------------"
|
||||
done
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
key="$1"
|
||||
case $key in
|
||||
@ -67,11 +133,6 @@ while [[ $# -gt 0 ]]; do
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
--build-local-code)
|
||||
BUILD_LOCAL_CODE="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
--load-examples)
|
||||
LOAD_EXAMPLES="$2"
|
||||
shift
|
||||
@ -82,28 +143,53 @@ while [[ $# -gt 0 ]]; do
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
-h|--help)
|
||||
help="true"
|
||||
shift
|
||||
;;
|
||||
--install-mode)
|
||||
DB_GPT_INSTALL_MODEL="$2"
|
||||
DB_GPT_INSTALL_MODE="$2"
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
EXTRAS)
|
||||
--extras)
|
||||
EXTRAS="$2"
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
--add-extras)
|
||||
ADDITIONAL_EXTRAS="$2"
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
--env-vars)
|
||||
BUILD_ENV_VARS="$2"
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
--add-env-vars)
|
||||
ADDITIONAL_ENV_VARS="$2"
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
--use-tsinghua-ubuntu)
|
||||
USE_TSINGHUA_UBUNTU="$2"
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
--python-version)
|
||||
PYTHON_VERSION="$2"
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
-f|--dockerfile)
|
||||
DOCKERFILE="$2"
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
--list-modes)
|
||||
list_modes
|
||||
exit 0
|
||||
;;
|
||||
-h|--help)
|
||||
help="true"
|
||||
shift
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
@ -112,46 +198,95 @@ while [[ $# -gt 0 ]]; do
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $help ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$DB_GPT_INSTALL_MODEL" != "default" ]; then
|
||||
IMAGE_NAME="$IMAGE_NAME-$DB_GPT_INSTALL_MODEL"
|
||||
echo "install mode is not 'default', set image name to: ${IMAGE_NAME}"
|
||||
fi
|
||||
|
||||
if [ -z "$IMAGE_NAME_ARGS" ]; then
|
||||
if [ "$DB_GPT_INSTALL_MODEL" == "openai" ]; then
|
||||
# Use cpu image
|
||||
BASE_IMAGE=$BASE_IMAGE_DEFAULT_CPU
|
||||
# Set extras if it is empty
|
||||
if [ -z "$EXTRAS" ]; then
|
||||
EXTRAS="proxy_openai,rag,storage_chromadb,cpu"
|
||||
# If installation mode is provided, get base_image, extras, and env_vars from configuration
|
||||
if [ -n "$DB_GPT_INSTALL_MODE" ]; then
|
||||
# Check if it's a valid installation mode
|
||||
if [ -n "${INSTALL_MODES["$DB_GPT_INSTALL_MODE,base_image"]}" ]; then
|
||||
# If user hasn't explicitly specified BASE_IMAGE, use the default value for this mode
|
||||
if [ "$BASE_IMAGE" == "$CUDA_BASE_IMAGE" ]; then
|
||||
BASE_IMAGE="${INSTALL_MODES["$DB_GPT_INSTALL_MODE,base_image"]}"
|
||||
fi
|
||||
|
||||
# If user hasn't explicitly specified EXTRAS, use the default value for this mode
|
||||
if [ -z "$EXTRAS" ]; then
|
||||
EXTRAS="${INSTALL_MODES["$DB_GPT_INSTALL_MODE,extras"]}"
|
||||
fi
|
||||
|
||||
# If additional extras are specified, add them to existing extras
|
||||
if [ -n "$ADDITIONAL_EXTRAS" ]; then
|
||||
if [ -z "$EXTRAS" ]; then
|
||||
EXTRAS="$ADDITIONAL_EXTRAS"
|
||||
else
|
||||
EXTRAS="$EXTRAS,$ADDITIONAL_EXTRAS"
|
||||
fi
|
||||
fi
|
||||
|
||||
# If user hasn't explicitly specified BUILD_ENV_VARS, use the default value for this mode
|
||||
if [ -z "$BUILD_ENV_VARS" ]; then
|
||||
BUILD_ENV_VARS="${INSTALL_MODES["$DB_GPT_INSTALL_MODE,env_vars"]}"
|
||||
fi
|
||||
|
||||
# If additional env_vars are specified, add them to existing env_vars
|
||||
if [ -n "$ADDITIONAL_ENV_VARS" ]; then
|
||||
if [ -z "$BUILD_ENV_VARS" ]; then
|
||||
BUILD_ENV_VARS="$ADDITIONAL_ENV_VARS"
|
||||
else
|
||||
BUILD_ENV_VARS="$BUILD_ENV_VARS $ADDITIONAL_ENV_VARS"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Warning: Unknown install mode '$DB_GPT_INSTALL_MODE'. Using defaults."
|
||||
fi
|
||||
|
||||
# Set image name suffix to installation mode
|
||||
if [ "$DB_GPT_INSTALL_MODE" != "default" ]; then
|
||||
IMAGE_NAME="$IMAGE_NAME-$DB_GPT_INSTALL_MODE"
|
||||
fi
|
||||
else
|
||||
# User input image is not empty
|
||||
BASE_IMAGE=$IMAGE_NAME_ARGS
|
||||
fi
|
||||
|
||||
# If image name argument is provided, use it as the image name
|
||||
if [ -n "$IMAGE_NAME_ARGS" ]; then
|
||||
IMAGE_NAME=$IMAGE_NAME_ARGS
|
||||
fi
|
||||
|
||||
# Add additional image name suffix
|
||||
if [ -n "$IMAGE_NAME_SUFFIX" ]; then
|
||||
IMAGE_NAME="$IMAGE_NAME-$IMAGE_NAME_SUFFIX"
|
||||
fi
|
||||
if [ -z "$EXTRAS" ]; then
|
||||
EXTRAS=$DEFAULT_EXTRAS
|
||||
|
||||
echo "Begin build docker image"
|
||||
echo "Base image: ${BASE_IMAGE}"
|
||||
echo "Target image name: ${IMAGE_NAME}"
|
||||
echo "Install mode: ${DB_GPT_INSTALL_MODE}"
|
||||
echo "Extras: ${EXTRAS}"
|
||||
echo "Additional Extras: ${ADDITIONAL_EXTRAS}"
|
||||
if [ -n "$BUILD_ENV_VARS" ]; then
|
||||
echo "Environment Variables: ${BUILD_ENV_VARS}"
|
||||
fi
|
||||
if [ -n "$ADDITIONAL_ENV_VARS" ]; then
|
||||
echo "Additional Environment Variables: ${ADDITIONAL_ENV_VARS}"
|
||||
fi
|
||||
echo "Python version: ${PYTHON_VERSION}"
|
||||
echo "Use Tsinghua Ubuntu mirror: ${USE_TSINGHUA_UBUNTU}"
|
||||
|
||||
# Build environment variable argument string
|
||||
BUILD_ENV_ARGS=""
|
||||
if [ -n "$BUILD_ENV_VARS" ]; then
|
||||
# Split environment variables and add them as build arguments
|
||||
for env_var in $BUILD_ENV_VARS; do
|
||||
var_name="${env_var%%=*}"
|
||||
BUILD_ENV_ARGS="$BUILD_ENV_ARGS --build-arg $env_var"
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Begin build docker image, base image: ${BASE_IMAGE}, target image name: ${IMAGE_NAME}, extras: ${EXTRAS}"
|
||||
|
||||
docker build $BUILD_NETWORK \
|
||||
--build-arg USE_TSINGHUA_UBUNTU=$USE_TSINGHUA_UBUNTU \
|
||||
--build-arg BASE_IMAGE=$BASE_IMAGE \
|
||||
--build-arg PIP_INDEX_URL=$PIP_INDEX_URL \
|
||||
--build-arg LANGUAGE=$LANGUAGE \
|
||||
--build-arg BUILD_LOCAL_CODE=$BUILD_LOCAL_CODE \
|
||||
--build-arg LOAD_EXAMPLES=$LOAD_EXAMPLES \
|
||||
--build-arg DB_GPT_INSTALL_MODEL=$DB_GPT_INSTALL_MODEL \
|
||||
--build-arg EXTRAS=$EXTRAS \
|
||||
--build-arg PYTHON_VERSION=$PYTHON_VERSION \
|
||||
$BUILD_ENV_ARGS \
|
||||
-f $DOCKERFILE \
|
||||
-t $IMAGE_NAME $WORK_DIR/../../
|
||||
-t $IMAGE_NAME $WORK_DIR/../../
|
339
docs/docs/installation/build_image.md
Normal file
339
docs/docs/installation/build_image.md
Normal file
@ -0,0 +1,339 @@
|
||||
---
|
||||
id: docker-build-guide
|
||||
title: DB-GPT Docker Build Guide
|
||||
sidebar_label: Docker Build Guide
|
||||
description: Comprehensive guide for building DB-GPT Docker images with various configurations
|
||||
keywords:
|
||||
- DB-GPT
|
||||
- Docker
|
||||
- Build
|
||||
- CUDA
|
||||
- OpenAI
|
||||
- VLLM
|
||||
- Llama-cpp
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
import CodeBlock from '@theme/CodeBlock';
|
||||
|
||||
# DB-GPT Docker Build Guide
|
||||
|
||||
This guide provides comprehensive instructions for building DB-GPT Docker images with various configurations using the `docker/base/build_image.sh` script.
|
||||
|
||||
## Overview
|
||||
|
||||
The DB-GPT build script allows you to create Docker images tailored to your specific requirements. You can choose from predefined installation modes or customize the build with specific extras, environment variables, and other settings.
|
||||
|
||||
## Available Installation Modes
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="default" label="Default" default>
|
||||
CUDA-based image with standard features.
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh
|
||||
```
|
||||
|
||||
Includes: CUDA support, proxy integrations (OpenAI, Ollama, Zhipuai, Anthropic, Qianfan, Tongyi), RAG capabilities, graph RAG, Hugging Face integration, and quantization support.
|
||||
</TabItem>
|
||||
<TabItem value="openai" label="OpenAI">
|
||||
CPU-based image optimized for OpenAI API usage.
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --install-mode openai
|
||||
```
|
||||
|
||||
Includes: Basic functionality, all proxy integrations, and RAG capabilities without GPU acceleration.
|
||||
</TabItem>
|
||||
<TabItem value="vllm" label="VLLM">
|
||||
CUDA-based image with VLLM for optimized inference.
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --install-mode vllm
|
||||
```
|
||||
|
||||
Includes: All default features plus VLLM support for high-performance inference.
|
||||
</TabItem>
|
||||
<TabItem value="llama-cpp" label="Llama-cpp">
|
||||
CUDA-based image with Llama-cpp support.
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --install-mode llama-cpp
|
||||
```
|
||||
|
||||
Includes: All default features plus Llama-cpp and Llama-cpp server with CUDA acceleration enabled via `CMAKE_ARGS="-DGGML_CUDA=ON"`.
|
||||
</TabItem>
|
||||
<TabItem value="full" label="Full">
|
||||
CUDA-based image with all available features.
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --install-mode full
|
||||
```
|
||||
|
||||
Includes: All features from other modes plus embedding capabilities.
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Basic Usage
|
||||
|
||||
### View Available Modes
|
||||
|
||||
To see all available installation modes and their configurations:
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --list-modes
|
||||
```
|
||||
|
||||
### Get Help
|
||||
|
||||
Display all available options:
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --help
|
||||
```
|
||||
|
||||
## Customization Options
|
||||
|
||||
### Python Version
|
||||
|
||||
DB-GPT requires Python 3.10 or higher. The default is Python 3.11, but you can specify a different version:
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --python-version 3.10
|
||||
```
|
||||
|
||||
### Custom Image Name
|
||||
|
||||
Set a custom name for the built image:
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --image-name mycompany/dbgpt
|
||||
```
|
||||
|
||||
### Image Name Suffix
|
||||
|
||||
Add a suffix to the image name for versioning or environment identification:
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --image-name-suffix v1.0
|
||||
```
|
||||
|
||||
This will generate `eosphorosai/dbgpt-v1.0` for the default mode or `eosphorosai/dbgpt-MODE-v1.0` for specific modes.
|
||||
|
||||
### PIP Mirror
|
||||
|
||||
Choose a different PIP index URL:
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --pip-index-url https://pypi.org/simple
|
||||
```
|
||||
|
||||
### Ubuntu Mirror
|
||||
|
||||
Control whether to use Tsinghua Ubuntu mirror:
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --use-tsinghua-ubuntu false
|
||||
```
|
||||
|
||||
### Language Preference
|
||||
|
||||
Set your preferred language (default is English):
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --language zh
|
||||
```
|
||||
|
||||
## Advanced Customization
|
||||
|
||||
### Custom Extras
|
||||
|
||||
You can customize the Python package extras installed in the image:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="override" label="Override Extras" default>
|
||||
Completely replace the default extras with your own selection:
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --extras "base,proxy_openai,rag,storage_chromadb"
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="add" label="Add Extras">
|
||||
Keep the default extras and add more:
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --add-extras "storage_milvus,storage_elasticsearch,datasource_postgres"
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="mode-specific" label="Mode-Specific">
|
||||
Add specific extras to a particular installation mode:
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --install-mode vllm --add-extras "storage_milvus,datasource_postgres"
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### Available Extra Options
|
||||
|
||||
Here are some useful extras you can add:
|
||||
|
||||
| Extra Package | Description |
|
||||
|--------------|-------------|
|
||||
| `storage_milvus` | Vector store integration with Milvus |
|
||||
| `storage_elasticsearch` | Vector store integration with Elasticsearch |
|
||||
| `datasource_postgres` | Database connector for PostgreSQL |
|
||||
| `vllm` | VLLM integration for optimized inference |
|
||||
| `llama_cpp` | Llama-cpp Python bindings |
|
||||
| `llama_cpp_server` | Llama-cpp HTTP server |
|
||||
|
||||
You can run `uv run install_help.py list` in your local DB-GPT repository to see all available extras.
|
||||
|
||||
### Environment Variables
|
||||
|
||||
DB-GPT build supports environment variables for specialized builds. The main environment variable used is `CMAKE_ARGS` which is particularly important for Llama-cpp compilation.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="override-env" label="Override Env Vars" default>
|
||||
Replace the default environment variables:
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --env-vars "CMAKE_ARGS=\"-DGGML_CUDA=ON -DLLAMA_CUBLAS=ON\""
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="add-env" label="Add Env Vars">
|
||||
Add additional environment variables:
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --install-mode llama-cpp --add-env-vars "FORCE_CMAKE=1"
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
:::note
|
||||
For Llama-cpp mode, `CMAKE_ARGS="-DGGML_CUDA=ON"` is automatically set to enable CUDA acceleration.
|
||||
:::
|
||||
|
||||
### Docker Network
|
||||
|
||||
Specify a Docker network for building:
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --network host
|
||||
```
|
||||
|
||||
### Custom Dockerfile
|
||||
|
||||
Use a custom Dockerfile:
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --dockerfile Dockerfile.custom
|
||||
```
|
||||
|
||||
## Example Scenarios
|
||||
|
||||
### Enterprise DB-GPT with PostgreSQL and Elasticsearch
|
||||
|
||||
Build a full-featured enterprise version with PostgreSQL and Elasticsearch support:
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --install-mode full \
|
||||
--add-extras "storage_elasticsearch,datasource_postgres" \
|
||||
--image-name-suffix enterprise \
|
||||
--python-version 3.10 \
|
||||
--load-examples false
|
||||
```
|
||||
|
||||
### Optimized Llama-cpp for Specific Hardware
|
||||
|
||||
Build with custom Llama-cpp optimization flags:
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --install-mode llama-cpp \
|
||||
--env-vars "CMAKE_ARGS=\"-DGGML_CUDA=ON -DGGML_AVX2=OFF -DGGML_AVX512=ON\"" \
|
||||
--python-version 3.11
|
||||
```
|
||||
|
||||
### Lightweight OpenAI Proxy
|
||||
|
||||
Build a minimal OpenAI proxy image:
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --install-mode openai \
|
||||
--use-tsinghua-ubuntu false \
|
||||
--pip-index-url https://pypi.org/simple \
|
||||
--load-examples false
|
||||
```
|
||||
|
||||
### Development Build with Milvus
|
||||
|
||||
Build a development version with Milvus support:
|
||||
|
||||
```bash
|
||||
bash docker/base/build_image.sh --install-mode vllm \
|
||||
--add-extras "storage_milvus" \
|
||||
--image-name-suffix dev
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
<details>
|
||||
<summary>Common Build Issues</summary>
|
||||
|
||||
### CUDA Not Found
|
||||
|
||||
If you encounter CUDA-related errors:
|
||||
|
||||
```bash
|
||||
# Try building with a different CUDA base image
|
||||
bash docker/base/build_image.sh --base-image nvidia/cuda:12.1.0-devel-ubuntu22.04
|
||||
```
|
||||
|
||||
### Package Installation Failures
|
||||
|
||||
If extras fail to install:
|
||||
|
||||
```bash
|
||||
# Try building with fewer extras to isolate the problem
|
||||
bash docker/base/build_image.sh --extras "base,proxy_openai,rag"
|
||||
```
|
||||
|
||||
### Network Issues
|
||||
|
||||
If you encounter network problems:
|
||||
|
||||
```bash
|
||||
# Use a specific network
|
||||
bash docker/base/build_image.sh --network host
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## API Reference
|
||||
|
||||
### Script Options
|
||||
|
||||
| Option | Description | Default Value |
|
||||
|--------|-------------|---------------|
|
||||
| `--install-mode` | Installation mode | `default` |
|
||||
| `--base-image` | Base Docker image | `nvidia/cuda:12.4.0-devel-ubuntu22.04` |
|
||||
| `--image-name` | Docker image name | `eosphorosai/dbgpt` |
|
||||
| `--image-name-suffix` | Suffix for image name | ` ` |
|
||||
| `--pip-index-url` | PIP mirror URL | `https://pypi.tuna.tsinghua.edu.cn/simple` |
|
||||
| `--language` | Interface language | `en` |
|
||||
| `--load-examples` | Load example data | `true` |
|
||||
| `--python-version` | Python version | `3.11` |
|
||||
| `--use-tsinghua-ubuntu` | Use Tsinghua Ubuntu mirror | `true` |
|
||||
| `--extras` | Extra packages to install | Mode dependent |
|
||||
| `--add-extras` | Additional extra packages | ` ` |
|
||||
| `--env-vars` | Build environment variables | Mode dependent |
|
||||
| `--add-env-vars` | Additional environment variables | ` ` |
|
||||
| `--dockerfile` | Dockerfile to use | `Dockerfile` |
|
||||
| `--network` | Docker network to use | ` ` |
|
||||
|
||||
## Additional Resources
|
||||
|
||||
- [DB-GPT Documentation](https://github.com/eosphoros-ai/DB-GPT)
|
||||
- [Docker Documentation](https://docs.docker.com/)
|
||||
- [CUDA Documentation](https://docs.nvidia.com/cuda/)
|
@ -1,112 +1,223 @@
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# Docker Deployment
|
||||
|
||||
## Docker image preparation
|
||||
|
||||
There are two ways to prepare a Docker image. 1. Pull from the official image 2. Build locally. You can **choose any one** during actual use.
|
||||
There are two ways to prepare a Docker image.
|
||||
1. Pull from the official image
|
||||
2. Build locally, see [Build Docker Image](./build_image.md)
|
||||
|
||||
1.Pulled from the official image repository, [Eosphoros AI Docker Hub](https://hub.docker.com/u/eosphorosai)
|
||||
```bash
|
||||
docker pull eosphorosai/dbgpt:latest
|
||||
```
|
||||
2.local build(optional)
|
||||
```bash
|
||||
bash docker/build_all_images.sh
|
||||
```
|
||||
Check the Docker image
|
||||
```bash
|
||||
# command
|
||||
docker images | grep "eosphorosai/dbgpt"
|
||||
You can **choose any one** during actual use.
|
||||
|
||||
# result
|
||||
--------------------------------------------------------------------------------------
|
||||
eosphorosai/dbgpt-allinone latest 349d49726588 27 seconds ago 15.1GB
|
||||
eosphorosai/dbgpt latest eb3cdc5b4ead About a minute ago 14.5GB
|
||||
```
|
||||
`eosphorosai/dbgpt` is the base image, which contains project dependencies and the sqlite database. The `eosphorosai/dbgpt-allinone` image is built from `eosphorosai/dbgpt`, which contains a MySQL database. Of course, in addition to pulling the Docker image, the project also provides Dockerfile files, which can be built directly through scripts in DB-GPT. Here are the build commands:
|
||||
|
||||
## Deploy With Proxy Model
|
||||
|
||||
In this deployment, you don't need an GPU environment.
|
||||
|
||||
1. Pull from the official image repository, [Eosphoros AI Docker Hub](https://hub.docker.com/u/eosphorosai)
|
||||
|
||||
```bash
|
||||
bash docker/build_all_images.sh
|
||||
docker pull eosphorosai/dbgpt-openai:latest
|
||||
```
|
||||
When using it, you need to specify specific parameters. The following is an example of specifying parameter construction:
|
||||
|
||||
```bash
|
||||
bash docker/build_all_images.sh \
|
||||
--base-image nvidia/cuda:11.8.0-runtime-ubuntu22.04 \
|
||||
--pip-index-url https://pypi.tuna.tsinghua.edu.cn/simple \
|
||||
--language zh
|
||||
```
|
||||
You can view the specific usage through the command `bash docker/build_all_images.sh --help`
|
||||
2. Run the Docker container
|
||||
|
||||
## Run Docker container
|
||||
|
||||
### Run through Sqlite database
|
||||
This example requires you previde a valid API key for the SiliconFlow API. You can obtain one by signing up at [SiliconFlow](https://siliconflow.cn/) and creating an API key at [API Key](https://cloud.siliconflow.cn/account/ak).
|
||||
|
||||
|
||||
```bash
|
||||
docker run --ipc host --gpus all -d \
|
||||
-p 5670:5670 \
|
||||
-e LOCAL_DB_TYPE=sqlite \
|
||||
-e LOCAL_DB_PATH=data/default_sqlite.db \
|
||||
-e LLM_MODEL=glm-4-9b-chat \
|
||||
-e LANGUAGE=zh \
|
||||
-v /data/models:/app/models \
|
||||
--name dbgpt \
|
||||
eosphorosai/dbgpt
|
||||
```
|
||||
Open the browser and visit [http://localhost:5670](http://localhost:5670)
|
||||
|
||||
- `-e LLM_MODEL=glm-4-9b-chat`, which means the base model uses `glm-4-9b-chat`. For more model usage, you can view the configuration in `/pilot/configs/model_config.LLM_MODEL_CONFIG`.
|
||||
- `-v /data/models:/app/models`, specifies the model file to be mounted. The directory `/data/models` is mounted in `/app/models` of the container. Of course, it can be replaced with other paths.
|
||||
|
||||
After the container is started, you can view the logs through the following command
|
||||
```bash
|
||||
docker logs dbgpt -f
|
||||
docker run -it --rm -e SILICONFLOW_API_KEY=${SILICONFLOW_API_KEY} \
|
||||
-p 5670:5670 --name dbgpt eosphorosai/dbgpt-openai
|
||||
```
|
||||
|
||||
### Run through MySQL database
|
||||
Please replace `${SILICONFLOW_API_KEY}` with your own API key.
|
||||
|
||||
|
||||
Then you can visit [http://localhost:5670](http://localhost:5670) in the browser.
|
||||
|
||||
|
||||
## Deploy With GPU (Local Model)
|
||||
|
||||
In this deployment, you need an GPU environment.
|
||||
|
||||
Before running the Docker container, you need to install the NVIDIA Container Toolkit. For more information, please refer to the official documentation [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html).
|
||||
|
||||
In this deployment, you will use a local model instead of downloading it from the Hugging Face or ModelScope model hub. This is useful if you have already downloaded the model to your local machine or if you want to use a model from a different source.
|
||||
|
||||
### Step 1: Download the Model
|
||||
|
||||
Before running the Docker container, you need to download the model to your local machine. You can use either Hugging Face or ModelScope (recommended for users in China) to download the model.
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="modelscope" label="Download from ModelScope">
|
||||
|
||||
1. Install `git` and `git-lfs` if you haven't already:
|
||||
|
||||
```bash
|
||||
sudo apt-get install git git-lfs
|
||||
```
|
||||
|
||||
2. Create a `models` directory in your current working directory:
|
||||
|
||||
```bash
|
||||
mkdir -p ./models
|
||||
```
|
||||
|
||||
3. Use `git` to clone the model repositories into the `models` directory:
|
||||
|
||||
```bash
|
||||
cd ./models
|
||||
git lfs install
|
||||
git clone https://www.modelscope.cn/Qwen/Qwen2.5-Coder-0.5B-Instruct.git
|
||||
git clone https://www.modelscope.cn/BAAI/bge-large-zh-v1.5.git
|
||||
cd ..
|
||||
```
|
||||
|
||||
This will download the models into the `./models/Qwen2.5-Coder-0.5B-Instruct` and `./models/bge-large-zh-v1.5` directories.
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="huggingface" label="Download from Hugging Face">
|
||||
|
||||
1. Install `git` and `git-lfs` if you haven't already:
|
||||
|
||||
```bash
|
||||
sudo apt-get install git git-lfs
|
||||
```
|
||||
|
||||
2. Create a `models` directory in your current working directory:
|
||||
|
||||
```bash
|
||||
mkdir -p ./models
|
||||
```
|
||||
|
||||
3. Use `git` to clone the model repositories into the `models` directory:
|
||||
|
||||
```bash
|
||||
cd ./models
|
||||
git lfs install
|
||||
git clone https://huggingface.co/Qwen/Qwen2.5-Coder-0.5B-Instruct
|
||||
git clone https://huggingface.co/BAAI/bge-large-zh-v1.5
|
||||
cd ..
|
||||
```
|
||||
|
||||
This will download the models into the `./models/Qwen2.5-Coder-0.5B-Instruct` and `./models/bge-large-zh-v1.5` directories.
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
---
|
||||
|
||||
### Step 2: Prepare the Configuration File
|
||||
|
||||
Create a `toml` file named `dbgpt-local-gpu.toml` and add the following content:
|
||||
|
||||
```toml
|
||||
[models]
|
||||
[[models.llms]]
|
||||
name = "Qwen2.5-Coder-0.5B-Instruct"
|
||||
provider = "hf"
|
||||
# Specify the model path in the local file system
|
||||
path = "/app/models/Qwen2.5-Coder-0.5B-Instruct"
|
||||
|
||||
[[models.embeddings]]
|
||||
name = "BAAI/bge-large-zh-v1.5"
|
||||
provider = "hf"
|
||||
# Specify the model path in the local file system
|
||||
path = "/app/models/bge-large-zh-v1.5"
|
||||
```
|
||||
|
||||
This configuration file specifies the local paths to the models inside the Docker container.
|
||||
|
||||
---
|
||||
|
||||
### Step 3: Run the Docker Container
|
||||
|
||||
Run the Docker container with the local `models` directory mounted:
|
||||
|
||||
```bash
|
||||
docker run --ipc host --gpus all -d -p 3306:3306 \
|
||||
-p 5670:5670 \
|
||||
-e LOCAL_DB_HOST=127.0.0.1 \
|
||||
-e LOCAL_DB_PASSWORD=aa123456 \
|
||||
-e MYSQL_ROOT_PASSWORD=aa123456 \
|
||||
-e LLM_MODEL=glm-4-9b-chat \
|
||||
-e LANGUAGE=zh \
|
||||
-v /data/models:/app/models \
|
||||
--name db-gpt-allinone \
|
||||
db-gpt-allinone
|
||||
```
|
||||
Open the browser and visit [http://localhost:5670](http://localhost:5670)
|
||||
|
||||
- `-e LLM_MODEL=glm-4-9b-chat`, which means the base model uses `glm-4-9b-chat`. For more model usage, you can view the configuration in `/pilot/configs/model_config.LLM_MODEL_CONFIG`.
|
||||
- `-v /data/models:/app/models`, specifies the model file to be mounted. The directory `/data/models` is mounted in `/app/models` of the container. Of course, it can be replaced with other paths.
|
||||
|
||||
After the container is started, you can view the logs through the following command
|
||||
```bash
|
||||
docker logs db-gpt-allinone -f
|
||||
docker run --ipc host --gpus all \
|
||||
-it --rm \
|
||||
-p 5670:5670 \
|
||||
-v ./dbgpt-local-gpu.toml:/app/configs/dbgpt-local-gpu.toml \
|
||||
-v ./models:/app/models \
|
||||
--name dbgpt \
|
||||
eosphorosai/dbgpt \
|
||||
dbgpt start webserver --config /app/configs/dbgpt-local-gpu.toml
|
||||
```
|
||||
|
||||
### Run through the OpenAI proxy model
|
||||
```bash
|
||||
PROXY_API_KEY="You api key"
|
||||
PROXY_SERVER_URL="https://api.openai.com/v1/chat/completions"
|
||||
docker run --gpus all -d -p 3306:3306 \
|
||||
-p 5670:5670 \
|
||||
-e LOCAL_DB_HOST=127.0.0.1 \
|
||||
-e LOCAL_DB_PASSWORD=aa123456 \
|
||||
-e MYSQL_ROOT_PASSWORD=aa123456 \
|
||||
-e LLM_MODEL=proxyllm \
|
||||
-e PROXY_API_KEY=$PROXY_API_KEY \
|
||||
-e PROXY_SERVER_URL=$PROXY_SERVER_URL \
|
||||
-e LANGUAGE=zh \
|
||||
-v /data/models/text2vec-large-chinese:/app/models/text2vec-large-chinese \
|
||||
--name db-gpt-allinone \
|
||||
db-gpt-allinone
|
||||
#### Explanation of the Command:
|
||||
- `--ipc host`: Enables host IPC mode for better performance.
|
||||
- `--gpus all`: Allows the container to use all available GPUs.
|
||||
- `-v ./dbgpt-local-gpu.toml:/app/configs/dbgpt-local-gpu.toml`: Mounts the local configuration file into the container.
|
||||
- `-v ./models:/app/models`: Mounts the local `models` directory into the container.
|
||||
- `eosphorosai/dbgpt`: The Docker image to use.
|
||||
- `dbgpt start webserver --config /app/configs/dbgpt-local-gpu.toml`: Starts the webserver with the specified configuration file.
|
||||
|
||||
---
|
||||
|
||||
### Step 4: Access the Application
|
||||
|
||||
Once the container is running, you can visit [http://localhost:5670](http://localhost:5670) in your browser to access the application.
|
||||
|
||||
---
|
||||
|
||||
### Step 5: Persist Data (Optional)
|
||||
|
||||
To ensure that your data is not lost when the container is stopped or removed, you can map the `pilot/data` and `pilot/message` directories to your local machine. These directories store application data and messages.
|
||||
|
||||
1. Create local directories for data persistence:
|
||||
|
||||
```bash
|
||||
mkdir -p ./pilot/data
|
||||
mkdir -p ./pilot/message
|
||||
mkdir -p ./pilot/alembic_versions
|
||||
```
|
||||
|
||||
2. Modify the `dbgpt-local-gpu.toml` configuration file to point to the correct paths:
|
||||
|
||||
```toml
|
||||
[service.web.database]
|
||||
type = "sqlite"
|
||||
path = "/app/pilot/message/dbgpt.db"
|
||||
```
|
||||
|
||||
3. Run the Docker container with the additional volume mounts:
|
||||
|
||||
```bash
|
||||
docker run --ipc host --gpus all \
|
||||
-it --rm \
|
||||
-p 5670:5670 \
|
||||
-v ./dbgpt-local-gpu.toml:/app/configs/dbgpt-local-gpu.toml \
|
||||
-v ./models:/app/models \
|
||||
-v ./pilot/data:/app/pilot/data \
|
||||
-v ./pilot/message:/app/pilot/message \
|
||||
-v ./pilot/alembic_versions:/app/pilot/meta_data/alembic/versions \
|
||||
--name dbgpt \
|
||||
eosphorosai/dbgpt \
|
||||
dbgpt start webserver --config /app/configs/dbgpt-local-gpu.toml
|
||||
```
|
||||
|
||||
This ensures that the `pilot/data` and `pilot/message` directories are persisted on your local machine.
|
||||
|
||||
---
|
||||
|
||||
### Summary of Directory Structure
|
||||
|
||||
After completing the steps, your directory structure should look like this:
|
||||
|
||||
```
|
||||
.
|
||||
├── dbgpt-local-gpu.toml
|
||||
├── models
|
||||
│ ├── Qwen2.5-Coder-0.5B-Instruct
|
||||
│ └── bge-large-zh-v1.5
|
||||
├── pilot
|
||||
│ ├── data
|
||||
│ └── message
|
||||
```
|
||||
- `-e LLM_MODEL=proxyllm`, set the model to serve the third-party model service API, which can be openai or fastchat interface.
|
||||
- `-v /data/models/text2vec-large-chinese:/app/models/text2vec-large-chinese`, sets the knowledge base embedding model to `text2vec`
|
||||
|
||||
Open the browser and visit [http://localhost:5670](http://localhost:5670)
|
||||
|
||||
This setup ensures that the models and application data are stored locally and mounted into the Docker container, allowing you to use them without losing data.
|
||||
```
|
||||
|
||||
|
@ -1,19 +1,26 @@
|
||||
# Docker-Compose Deployment
|
||||
|
||||
## Run via Docker-Compose
|
||||
```python
|
||||
$ docker compose up -d
|
||||
------------------------------------------
|
||||
[+] Building 0.0s (0/0)
|
||||
[+] Running 2/2
|
||||
✔ Container db-gpt-db-1 Started 0.4s
|
||||
✔ Container db-gpt-webserver-1 Started
|
||||
|
||||
This example requires you previde a valid API key for the SiliconFlow API. You can obtain one by signing up at [SiliconFlow](https://siliconflow.cn/) and creating an API key at [API Key](https://cloud.siliconflow.cn/account/ak).
|
||||
|
||||
|
||||
```bash
|
||||
SILICONFLOW_API_KEY=${SILICONFLOW_API_KEY} docker compose up -d
|
||||
```
|
||||
|
||||
You will see the following output if the deployment is successful.
|
||||
```bash
|
||||
[+] Running 3/3
|
||||
✔ Network dbgptnet Created 0.0s
|
||||
✔ Container db-gpt-db-1 Started 0.2s
|
||||
✔ Container db-gpt-webserver-1 Started 0.2s
|
||||
```
|
||||
|
||||
|
||||
## View log
|
||||
```python
|
||||
$ docker logs db-gpt-webserver-1 -f
|
||||
```bash
|
||||
docker logs db-gpt-webserver-1 -f
|
||||
```
|
||||
|
||||
:::info note
|
||||
|
@ -7,7 +7,7 @@ In this example, we will show how to use the ClickHouse as in DB-GPT Datasource.
|
||||
First, you need to install the `dbgpt clickhouse datasource` library.
|
||||
|
||||
```bash
|
||||
uv sync --all-packages --frozen \
|
||||
uv sync --all-packages \
|
||||
--extra "base" \
|
||||
--extra "datasource_clickhouse" \
|
||||
--extra "rag" \
|
||||
|
@ -10,7 +10,7 @@ First, you need to install the `dbgpt duckdb datasource` library.
|
||||
|
||||
```bash
|
||||
|
||||
uv sync --all-packages --frozen \
|
||||
uv sync --all-packages \
|
||||
--extra "base" \
|
||||
--extra "datasource_duckdb" \
|
||||
--extra "rag" \
|
||||
|
@ -11,7 +11,7 @@ You can refer to the python example file `DB-GPT/examples/rag/graph_rag_example.
|
||||
First, you need to install the `dbgpt graph_rag` library.
|
||||
|
||||
```bash
|
||||
uv sync --all-packages --frozen \
|
||||
uv sync --all-packages \
|
||||
--extra "base" \
|
||||
--extra "proxy_openai" \
|
||||
--extra "rag" \
|
||||
|
@ -7,7 +7,7 @@ In this example, we will show how to use the Hive as in DB-GPT Datasource. Using
|
||||
First, you need to install the `dbgpt hive datasource` library.
|
||||
|
||||
```bash
|
||||
uv sync --all-packages --frozen \
|
||||
uv sync --all-packages \
|
||||
--extra "base" \
|
||||
--extra "datasource_hive" \
|
||||
--extra "rag" \
|
||||
|
@ -9,7 +9,7 @@ In this example, we will show how to use the Milvus as in DB-GPT RAG Storage. Us
|
||||
First, you need to install the `dbgpt milvus storage` library.
|
||||
|
||||
```bash
|
||||
uv sync --all-packages --frozen \
|
||||
uv sync --all-packages \
|
||||
--extra "base" \
|
||||
--extra "proxy_openai" \
|
||||
--extra "rag" \
|
||||
|
@ -8,7 +8,7 @@ First, you need to install the `dbgpt mssql datasource` library.
|
||||
|
||||
```bash
|
||||
|
||||
uv sync --all-packages --frozen \
|
||||
uv sync --all-packages \
|
||||
--extra "base" \
|
||||
--extra "datasource_mssql" \
|
||||
--extra "rag" \
|
||||
|
@ -9,7 +9,7 @@ In this example, we will show how to use the Oceanbase Vector as in DB-GPT RAG S
|
||||
First, you need to install the `dbgpt Oceanbase Vector storage` library.
|
||||
|
||||
```bash
|
||||
uv sync --all-packages --frozen \
|
||||
uv sync --all-packages \
|
||||
--extra "base" \
|
||||
--extra "proxy_openai" \
|
||||
--extra "rag" \
|
||||
|
@ -10,7 +10,7 @@ First, you need to install the `dbgpt postgres datasource` library.
|
||||
|
||||
```bash
|
||||
|
||||
uv sync --all-packages --frozen \
|
||||
uv sync --all-packages \
|
||||
--extra "base" \
|
||||
--extra "datasource_postgres" \
|
||||
--extra "rag" \
|
||||
|
@ -80,7 +80,7 @@ uv --version
|
||||
|
||||
```bash
|
||||
# Use uv to install dependencies needed for OpenAI proxy
|
||||
uv sync --all-packages --frozen \
|
||||
uv sync --all-packages \
|
||||
--extra "base" \
|
||||
--extra "proxy_openai" \
|
||||
--extra "rag" \
|
||||
@ -120,7 +120,7 @@ uv run python packages/dbgpt-app/src/dbgpt_app/dbgpt_server.py --config configs/
|
||||
|
||||
```bash
|
||||
# Use uv to install dependencies needed for OpenAI proxy
|
||||
uv sync --all-packages --frozen \
|
||||
uv sync --all-packages \
|
||||
--extra "base" \
|
||||
--extra "proxy_openai" \
|
||||
--extra "rag" \
|
||||
@ -169,8 +169,9 @@ uv run python packages/dbgpt-app/src/dbgpt_app/dbgpt_server.py --config configs/
|
||||
```bash
|
||||
# Use uv to install dependencies needed for GLM4
|
||||
# Install core dependencies and select desired extensions
|
||||
uv sync --all-packages --frozen \
|
||||
uv sync --all-packages \
|
||||
--extra "base" \
|
||||
--extra "cuda121" \
|
||||
--extra "hf" \
|
||||
--extra "rag" \
|
||||
--extra "storage_chromadb" \
|
||||
@ -228,20 +229,6 @@ npm run dev
|
||||
Open your browser and visit [`http://localhost:3000`](http://localhost:3000)
|
||||
|
||||
|
||||
#### More descriptions
|
||||
|
||||
| environment variables | default value | description |
|
||||
|-------------------------------------|------------------|-----------------------|
|
||||
| `llama_cpp_prompt_template` | None | Prompt template now supports `zero_shot, vicuna_v1.1,alpaca,llama-2,baichuan-chat,internlm-chat`. If it is None, the model Prompt template can be automatically obtained according to the model path. |
|
||||
| `llama_cpp_model_path` | None | model path |
|
||||
| `llama_cpp_n_gpu_layers` | 1000000000 | How many network layers to transfer to the GPU, set this to 1000000000 to transfer all layers to the GPU. If your GPU is low on memory, you can set a lower number, for example: 10. |
|
||||
| `llama_cpp_n_threads` | None | The number of threads to use. If None, the number of threads will be determined automatically. |
|
||||
| `llama_cpp_n_batch` | 512 | The maximum number of prompt tokens to be batched together when calling llama_eval |
|
||||
| `llama_cpp_n_gqa` | None | For the llama-2 70B model, Grouped-query attention must be 8. |
|
||||
| `llama_cpp_rms_norm_eps` | 5e-06 | For the llama-2 model, 5e-6 is a good value. |
|
||||
| `llama_cpp_cache_capacity` | None | Maximum model cache size. For example: 2000MiB, 2GiB |
|
||||
| `llama_cpp_prefer_cpu` | False | If a GPU is available, the GPU will be used first by default unless prefer_cpu=False is configured. |
|
||||
|
||||
## Install DB-GPT Application Database
|
||||
<Tabs
|
||||
defaultValue="sqlite"
|
||||
@ -258,6 +245,13 @@ they will be created automatically for you by default.
|
||||
|
||||
:::
|
||||
|
||||
Modify your toml configuration file to use SQLite as the database(Is the default setting).
|
||||
```toml
|
||||
[service.web.database]
|
||||
type = "sqlite"
|
||||
path = "pilot/meta_data/dbgpt.db"
|
||||
```
|
||||
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="mysql" label="MySQL">
|
||||
@ -274,15 +268,18 @@ After version 0.4.7, we removed the automatic generation of MySQL database Schem
|
||||
$ mysql -h127.0.0.1 -uroot -p{your_password} < ./assets/schema/dbgpt.sql
|
||||
```
|
||||
|
||||
2. Second, set DB-GPT MySQL database settings in `.env` file.
|
||||
2. Second, modify your toml configuration file to use MySQL as the database.
|
||||
|
||||
```bash
|
||||
LOCAL_DB_TYPE=mysql
|
||||
LOCAL_DB_USER= {your username}
|
||||
LOCAL_DB_PASSWORD={your_password}
|
||||
LOCAL_DB_HOST=127.0.0.1
|
||||
LOCAL_DB_PORT=3306
|
||||
```toml
|
||||
[service.web.database]
|
||||
type = "mysql"
|
||||
host = "127.0.0.1"
|
||||
port = 3306
|
||||
user = "root"
|
||||
database = "dbgpt"
|
||||
password = "aa123456"
|
||||
```
|
||||
Please replace the `host`, `port`, `user`, `database`, and `password` with your own MySQL database settings.
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
@ -165,8 +165,10 @@ uv sync --all-packages \
|
||||
--extra "rag" \
|
||||
--extra "storage_chromadb" \
|
||||
--extra "dbgpts" \
|
||||
--extra "hf"
|
||||
--extra "hf" \
|
||||
--extra "cpu"
|
||||
```
|
||||
|
||||
**Model Configurations**:
|
||||
```toml
|
||||
# Model Configurations
|
||||
@ -205,6 +207,7 @@ uv run python packages/dbgpt-app/src/dbgpt_app/dbgpt_server.py --config configs/
|
||||
# Install core dependencies and select desired extensions
|
||||
uv sync --all-packages \
|
||||
--extra "base" \
|
||||
--extra "cuda121" \
|
||||
--extra "hf" \
|
||||
--extra "rag" \
|
||||
--extra "storage_chromadb" \
|
||||
@ -249,6 +252,8 @@ uv run dbgpt start webserver --config configs/dbgpt-local-glm.toml
|
||||
# Install core dependencies and select desired extensions
|
||||
uv sync --all-packages \
|
||||
--extra "base" \
|
||||
--extra "hf" \
|
||||
--extra "cuda121" \
|
||||
--extra "vllm" \
|
||||
--extra "rag" \
|
||||
--extra "storage_chromadb" \
|
||||
@ -295,6 +300,8 @@ If you has a Nvidia GPU, you can enable the CUDA support by setting the environm
|
||||
# Install core dependencies and select desired extensions
|
||||
CMAKE_ARGS="-DGGML_CUDA=ON" uv sync --all-packages \
|
||||
--extra "base" \
|
||||
--extra "hf" \
|
||||
--extra "cuda121" \
|
||||
--extra "llama_cpp" \
|
||||
--extra "rag" \
|
||||
--extra "storage_chromadb" \
|
||||
@ -308,6 +315,7 @@ Otherwise, run the following command to install dependencies without CUDA suppor
|
||||
# Install core dependencies and select desired extensions
|
||||
uv sync --all-packages \
|
||||
--extra "base" \
|
||||
--extra "hf" \
|
||||
--extra "llama_cpp" \
|
||||
--extra "rag" \
|
||||
--extra "storage_chromadb" \
|
||||
@ -388,6 +396,35 @@ uv run python packages/dbgpt-app/src/dbgpt_app/dbgpt_server.py --config configs/
|
||||
</Tabs>
|
||||
|
||||
|
||||
## DB-GPT Install Help Tool
|
||||
|
||||
If you need help with the installation, you can use the `uv` script to get help.
|
||||
|
||||
```bash
|
||||
uv run install_help.py --help
|
||||
```
|
||||
|
||||
## Generate Install Command
|
||||
|
||||
You can use the `uv` script to generate the install command in the interactive mode.
|
||||
|
||||
```bash
|
||||
uv run install_help.py install-cmd --interactive
|
||||
```
|
||||
|
||||
And you can generate an install command with all the dependencies needed for the OpenAI proxy model.
|
||||
|
||||
```bash
|
||||
uv run install_help.py install-cmd --all
|
||||
```
|
||||
|
||||
You can found all the dependencies and extras.
|
||||
|
||||
```bash
|
||||
uv run install_help.py list
|
||||
```
|
||||
|
||||
|
||||
## Visit Website
|
||||
|
||||
Open your browser and visit [`http://localhost:5670`](http://localhost:5670)
|
||||
|
@ -124,6 +124,10 @@ const sidebars = {
|
||||
type: 'doc',
|
||||
id: 'installation/docker_compose',
|
||||
},
|
||||
{
|
||||
type: 'doc',
|
||||
id: 'installation/docker-build-guide',
|
||||
},
|
||||
{
|
||||
type: 'category',
|
||||
label: 'Model Service Deployment',
|
||||
|
@ -232,7 +232,7 @@ with DAG("simple_nl_schema_sql_chart_example") as dag:
|
||||
)
|
||||
request_handle_task = RequestHandleOperator()
|
||||
query_operator = MapOperator(lambda request: request["query"])
|
||||
llm = OpenAILLMClient()
|
||||
llm = (OpenAILLMClient(api_key=os.getenv("OPENAI_API_KEY", "your api key")),)
|
||||
model_name = "gpt-3.5-turbo"
|
||||
retriever_task = SchemaLinkingOperator(
|
||||
connector=_create_temporary_connection(), llm=llm, model_name=model_name
|
||||
|
@ -29,6 +29,7 @@
|
||||
}'
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import Dict
|
||||
|
||||
from dbgpt._private.pydantic import BaseModel, Field
|
||||
@ -61,7 +62,10 @@ with DAG("dbgpt_awel_simple_rag_rewrite_example") as dag:
|
||||
)
|
||||
request_handle_task = RequestHandleOperator()
|
||||
# build query rewrite operator
|
||||
rewrite_task = QueryRewriteOperator(llm_client=OpenAILLMClient(), nums=2)
|
||||
rewrite_task = QueryRewriteOperator(
|
||||
llm_client=OpenAILLMClient(api_key=os.getenv("OPENAI_API_KEY", "your api key")),
|
||||
nums=2,
|
||||
)
|
||||
trigger >> request_handle_task >> rewrite_task
|
||||
|
||||
|
||||
|
@ -27,6 +27,7 @@ This example shows how to use AWEL to build a simple rag summary example.
|
||||
}'
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import Dict
|
||||
|
||||
from dbgpt._private.pydantic import BaseModel, Field
|
||||
@ -62,7 +63,8 @@ with DAG("dbgpt_awel_simple_rag_summary_example") as dag:
|
||||
knowledge_operator = KnowledgeOperator(knowledge_type=KnowledgeType.URL.name)
|
||||
# build summary assembler operator
|
||||
summary_operator = SummaryAssemblerOperator(
|
||||
llm_client=OpenAILLMClient(), language="en"
|
||||
llm_client=OpenAILLMClient(api_key=os.getenv("OPENAI_API_KEY", "your api key")),
|
||||
language="en",
|
||||
)
|
||||
(
|
||||
trigger
|
||||
|
651
install_help.py
Executable file
651
install_help.py
Executable file
@ -0,0 +1,651 @@
|
||||
#!/usr/bin/env python
|
||||
# /// script
|
||||
# dependencies = [
|
||||
# "tomli",
|
||||
# "click",
|
||||
# "inquirer",
|
||||
# ]
|
||||
# [tool.uv]
|
||||
# exclude-newer = "2025-03-07T00:00:00Z"
|
||||
# ///
|
||||
import os
|
||||
import tomli
|
||||
import glob
|
||||
import click
|
||||
import inquirer
|
||||
from pathlib import Path
|
||||
from typing import Dict, Any
|
||||
|
||||
|
||||
# For I18N support, we use a simple class to store translations and a global instance
|
||||
# to access it.
|
||||
class I18N:
|
||||
# Define supported languages in current install help script
|
||||
SUPPORTED_LANGUAGES = ['en', 'zh']
|
||||
|
||||
# The translation dictionary contains a mapping from language code to a dictionary
|
||||
TRANSLATIONS = {
|
||||
'en': {
|
||||
# Common
|
||||
'workspace_not_found': "Workspace root not found.",
|
||||
'cannot_parse': "Cannot parse {}: {}",
|
||||
'no_extras_defined': "No extras defined",
|
||||
'no_extras_found': "No workspace or extras found.",
|
||||
'operation_canceled': "Operation canceled.",
|
||||
'available_packages': "Available packages: {}",
|
||||
'copy_command': "Please copy the above command to execute in terminal. For more help, run:",
|
||||
'finished': "Finished!",
|
||||
|
||||
# Description of the CLI command
|
||||
'cli_description': "UV Workspace Extras Helper - Manage optional dependencies in UV workspace",
|
||||
'list_cmd_description': "List all extras in the workspace",
|
||||
'install_cmd_description': "Generate installation commands for extras",
|
||||
'deploy_cmd_description': "Use predefined deployment templates",
|
||||
|
||||
# Option descriptions
|
||||
'verbose_option': "Show detailed dependency information",
|
||||
'interactive_option': "Interactive guide to generate installation commands",
|
||||
'all_option': "Generate command to install all extras",
|
||||
'china_option': "Use Tsinghua PyPI mirror for faster installation in China",
|
||||
'preset_option': "Use predefined deployment template",
|
||||
'list_presets_option': "List all predefined deployment templates",
|
||||
'language_option': "Specify language (en/zh)",
|
||||
|
||||
# List command
|
||||
'extras_in_workspace': "Extras in workspace:\n",
|
||||
'available_extras': "Available extras:",
|
||||
'dependencies': "dependencies",
|
||||
|
||||
# Installation command
|
||||
'install_all_extras': "# Install all optional features:",
|
||||
'install_extras_for': "# Install {} feature for {}:",
|
||||
'package_not_in_workspace': "Error: Package '{}' not in workspace or has no extras defined.",
|
||||
'package_no_extras': "Package '{}' has no extras defined.",
|
||||
'extra_not_in_package': "Error: Extra '{}' not found in package '{}'.",
|
||||
'available_extras_in_package': "Available extras: {}",
|
||||
|
||||
# Interactive installation
|
||||
'welcome': "Welcome to DB-GPT Installation Assistant!",
|
||||
'help_message': "This tool will help you generate the correct installation commands.\n",
|
||||
'select_mode': "Please select installation mode",
|
||||
'select_extras': "Please select extras to install (space to select/deselect, enter to confirm)",
|
||||
'installation_info': "📋 Installation Information",
|
||||
'selected_mode': "📦 Selected mode: {}",
|
||||
'description': "📝 Description: {}",
|
||||
'note': "ℹ️ Note: {}",
|
||||
'will_install': "🧩 Will install the following extras: {}",
|
||||
'config_file': "⚙️ Configuration file: {}",
|
||||
'generate_command': "Generate installation command?",
|
||||
'installation_command': "🚀 Installation Command",
|
||||
'startup_command': "🏃 Startup Command",
|
||||
'further_configuration': "⚠️ Further Configuration",
|
||||
'set_api_key': "Please make sure you set the correct API Key in the configuration file {}",
|
||||
'set_model_path': "Please make sure you set the correct model path in the configuration file {}",
|
||||
|
||||
# Deployment command
|
||||
'available_presets': "Available deployment presets:",
|
||||
'specify_preset': "Please specify a deployment preset name, or use --list to view all presets",
|
||||
'preset_not_found': "Error: Preset '{}' not found",
|
||||
'available_presets_list': "Available presets: {}",
|
||||
'using_preset': "Using preset '{}' to generate deployment command",
|
||||
|
||||
# Preset descriptions
|
||||
'openai_preset': "OpenAI Proxy Mode",
|
||||
'openai_desc': "Using OpenAI API as proxy, suitable for environments without GPU",
|
||||
'openai_note': "Requires OpenAI API Key",
|
||||
|
||||
'deepseek_preset': "DeepSeek Proxy Mode",
|
||||
'deepseek_desc': "Using DeepSeek API as proxy, suitable for environments without GPU",
|
||||
'deepseek_note': "Requires DeepSeek API Key",
|
||||
|
||||
'glm4_preset': "GLM4 Local Mode",
|
||||
'glm4_desc': "Using local GLM4 model, requires GPU environment",
|
||||
'glm4_note': "Requires local model path configuration",
|
||||
|
||||
'vllm_preset': "VLLM Local Mode",
|
||||
'vllm_desc': "Using VLLM framework to load local model, requires GPU environment",
|
||||
'vllm_note': "Requires local model path configuration",
|
||||
|
||||
'llama_cpp_preset': "LLAMA_CPP Local Mode",
|
||||
'llama_cpp_desc': "Using LLAMA.cpp framework to load local model, can run on CPU but GPU recommended",
|
||||
'llama_cpp_note': "Requires local model path configuration, for CUDA support set CMAKE_ARGS=\"-DGGML_CUDA=ON\"",
|
||||
|
||||
'ollama_preset': "Ollama Proxy Mode",
|
||||
'ollama_desc': "Using Ollama as proxy, suitable for environments without GPU",
|
||||
'ollama_note': "Requires Ollama API Base",
|
||||
|
||||
'custom_preset': "Custom Mode",
|
||||
'custom_desc': "Manually select needed extras",
|
||||
'custom_note': "Suitable for advanced users"
|
||||
},
|
||||
'zh': {
|
||||
# Common
|
||||
'workspace_not_found': "未找到工作区根目录",
|
||||
'cannot_parse': "无法解析 {}: {}",
|
||||
'no_extras_defined': "没有定义 extras",
|
||||
'no_extras_found': "未找到工作区或没有可选依赖。",
|
||||
'operation_canceled': "操作已取消。",
|
||||
'available_packages': "可用的包: {}",
|
||||
'copy_command': "请复制上面的命令到终端执行。如需更多帮助,请运行:",
|
||||
'finished': "完成!",
|
||||
|
||||
# Description of the CLI command
|
||||
'cli_description': "UV Workspace Extras Helper - 管理UV工作区的可选依赖",
|
||||
'list_cmd_description': "列出工作区中的所有extras",
|
||||
'install_cmd_description': "生成安装extras的命令",
|
||||
'deploy_cmd_description': "使用预设的部署方案",
|
||||
|
||||
# Option descriptions
|
||||
'verbose_option': "显示详细依赖信息",
|
||||
'interactive_option': "交互式引导生成安装命令",
|
||||
'all_option': "生成安装所有extras的命令",
|
||||
'china_option': "使用清华pip镜像源加速安装",
|
||||
'preset_option': "使用预设的部署方案",
|
||||
'list_presets_option': "列出所有预设部署方案",
|
||||
'language_option': "指定语言 (en/zh)",
|
||||
|
||||
# List command
|
||||
'extras_in_workspace': "工作区中的可选依赖 (extras):\n",
|
||||
'available_extras': "可用的 extras:",
|
||||
'dependencies': "个依赖",
|
||||
|
||||
# Installation command
|
||||
'install_all_extras': "# 安装所有可选功能:",
|
||||
'install_extras_for': "# 安装 {} 的 {} 功能:",
|
||||
'package_not_in_workspace': "错误: 包 '{}' 不在工作区中或没有定义extras。",
|
||||
'package_no_extras': "包 '{}' 没有定义extras。",
|
||||
'extra_not_in_package': "错误: 包 '{}' 中没有名为 '{}' 的extra。",
|
||||
'available_extras_in_package': "可用的extras: {}",
|
||||
|
||||
# Interactive installation
|
||||
'welcome': "欢迎使用 DB-GPT 安装引导助手!",
|
||||
'help_message': "这个工具将帮助你生成正确的安装命令。\n",
|
||||
'select_mode': "请选择安装模式",
|
||||
'select_extras': "请选择需要安装的extras(空格选择/取消,回车确认)",
|
||||
'installation_info': "📋 安装信息",
|
||||
'selected_mode': "📦 选择的模式: {}",
|
||||
'description': "📝 描述: {}",
|
||||
'note': "ℹ️ 注意事项: {}",
|
||||
'will_install': "🧩 将安装以下extras: {}",
|
||||
'config_file': "⚙️ 配置文件: {}",
|
||||
'generate_command': "是否生成安装命令?",
|
||||
'installation_command': "🚀 安装命令",
|
||||
'startup_command': "🏃 启动命令",
|
||||
'further_configuration': "⚠️ 后续配置",
|
||||
'set_api_key': "请确保在配置文件 {} 中设置了正确的API Key",
|
||||
'set_model_path': "请确保在配置文件 {} 中设置了正确的模型路径",
|
||||
|
||||
# Deployment command
|
||||
'available_presets': "可用的部署预设:",
|
||||
'specify_preset': "请指定部署预设名称,或使用 --list 查看所有预设",
|
||||
'preset_not_found': "错误: 未找到预设 '{}'",
|
||||
'available_presets_list': "可用的预设: {}",
|
||||
'using_preset': "使用预设 '{}' 生成部署命令",
|
||||
|
||||
# Preset descriptions
|
||||
'openai_preset': "OpenAI 代理模式",
|
||||
'openai_desc': "使用OpenAI API作为代理,适合无GPU环境",
|
||||
'openai_note': "需要提供OpenAI API Key",
|
||||
|
||||
'deepseek_preset': "DeepSeek 代理模式",
|
||||
'deepseek_desc': "使用DeepSeek API作为代理,适合无GPU环境",
|
||||
'deepseek_note': "需要提供DeepSeek API Key",
|
||||
|
||||
'glm4_preset': "GLM4 本地模式",
|
||||
'glm4_desc': "使用本地GLM4模型,需要GPU环境",
|
||||
'glm4_note': "需要配置本地模型路径",
|
||||
|
||||
'vllm_preset': "VLLM 本地模式",
|
||||
'vllm_desc': "使用VLLM框架加载本地模型,需要GPU环境",
|
||||
'vllm_note': "需要配置本地模型路径",
|
||||
|
||||
'llama_cpp_preset': "LLAMA_CPP 本地模式",
|
||||
'llama_cpp_desc': "使用LLAMA.cpp框架加载本地模型,CPU也可运行但推荐GPU",
|
||||
'llama_cpp_note': "需要配置本地模型路径,启用CUDA需设置CMAKE_ARGS=\"-DGGML_CUDA=ON\"",
|
||||
|
||||
'ollama_preset': "Ollama 代理模式",
|
||||
'ollama_desc': "使用Ollama作为代理,适合无GPU环境",
|
||||
'ollama_note': "需要提供Ollama API Base",
|
||||
|
||||
'custom_preset': "自定义模式",
|
||||
'custom_desc': "手动选择需要的extras",
|
||||
'custom_note': "适合高级用户"
|
||||
}
|
||||
}
|
||||
|
||||
def __init__(self, lang=None):
|
||||
"""Initialize the I18N instance with the specified language"""
|
||||
# If language is not specified, try to get from environment
|
||||
if not lang:
|
||||
try:
|
||||
import locale
|
||||
try:
|
||||
# First try to get the locale from the environment
|
||||
lang = locale.getlocale()[0]
|
||||
except (AttributeError, ValueError):
|
||||
try:
|
||||
lang = locale.getdefaultlocale()[0]
|
||||
except (AttributeError, ValueError):
|
||||
lang = 'en'
|
||||
|
||||
if lang:
|
||||
lang = lang.split('_')[0]
|
||||
else:
|
||||
lang = 'en'
|
||||
except (ImportError, AttributeError, ValueError):
|
||||
lang = 'en'
|
||||
|
||||
# If the language is not supported, default to English
|
||||
if lang not in self.SUPPORTED_LANGUAGES:
|
||||
lang = 'en'
|
||||
|
||||
self.lang = lang
|
||||
|
||||
def get(self, key):
|
||||
"""Get the translation for the specified key"""
|
||||
return self.TRANSLATIONS.get(self.lang, {}).get(key, key)
|
||||
|
||||
|
||||
|
||||
i18n = I18N()
|
||||
|
||||
|
||||
def set_language(lang):
|
||||
"""Set the global language for the script"""
|
||||
global i18n
|
||||
i18n = I18N(lang)
|
||||
|
||||
|
||||
def extract_workspace_extras():
|
||||
"""Determine the workspace root and extract extras dependencies for all packages"""
|
||||
# First locate the workspace root (directory containing pyproject.toml with
|
||||
# tool.uv.workspace)
|
||||
current_dir = os.getcwd()
|
||||
workspace_root = None
|
||||
|
||||
# Find the workspace root
|
||||
while current_dir != os.path.dirname(current_dir): # Stop at root
|
||||
pyproject_path = os.path.join(current_dir, "pyproject.toml")
|
||||
if os.path.exists(pyproject_path):
|
||||
try:
|
||||
with open(pyproject_path, "rb") as f:
|
||||
pyproject_data = tomli.load(f)
|
||||
if pyproject_data.get("tool", {}).get("uv", {}).get("workspace"):
|
||||
workspace_root = current_dir
|
||||
break
|
||||
except Exception as e:
|
||||
print(i18n.get('cannot_parse').format(pyproject_path, e))
|
||||
current_dir = os.path.dirname(current_dir)
|
||||
|
||||
if not workspace_root:
|
||||
print(i18n.get('workspace_not_found'))
|
||||
return {}
|
||||
|
||||
# Read the workspace configuration
|
||||
with open(os.path.join(workspace_root, "pyproject.toml"), "rb") as f:
|
||||
root_data = tomli.load(f)
|
||||
|
||||
workspace_config = root_data.get("tool", {}).get("uv", {}).get("workspace", {})
|
||||
members_patterns = workspace_config.get("members", [])
|
||||
exclude_patterns = workspace_config.get("exclude", [])
|
||||
|
||||
# Extract all member packages
|
||||
member_dirs = []
|
||||
for pattern in members_patterns:
|
||||
# Convert glob pattern to absolute path
|
||||
full_pattern = os.path.join(workspace_root, pattern)
|
||||
matches = glob.glob(full_pattern, recursive=True)
|
||||
|
||||
for match in matches:
|
||||
if os.path.isdir(match) and os.path.exists(os.path.join(match, "pyproject.toml")):
|
||||
# Check if the directory should be excluded
|
||||
should_exclude = False
|
||||
for exclude_pattern in exclude_patterns:
|
||||
if Path(match).match(os.path.join(workspace_root, exclude_pattern)):
|
||||
should_exclude = True
|
||||
break
|
||||
|
||||
if not should_exclude:
|
||||
member_dirs.append(match)
|
||||
|
||||
# Add the workspace root as a member package
|
||||
member_dirs.append(workspace_root)
|
||||
|
||||
# Extract extras for each member package
|
||||
all_extras = {}
|
||||
|
||||
for member_dir in member_dirs:
|
||||
member_path = os.path.join(member_dir, "pyproject.toml")
|
||||
try:
|
||||
with open(member_path, "rb") as f:
|
||||
member_data = tomli.load(f)
|
||||
|
||||
project_name = member_data.get("project", {}).get("name", os.path.basename(member_dir))
|
||||
optional_deps = member_data.get("project", {}).get("optional-dependencies", {})
|
||||
|
||||
if optional_deps:
|
||||
all_extras[project_name] = {
|
||||
"path": member_dir,
|
||||
"extras": list(optional_deps.keys()),
|
||||
"details": optional_deps
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
print(i18n.get('cannot_parse').format(member_path, e))
|
||||
|
||||
return all_extras
|
||||
|
||||
|
||||
# Preset deployment templates
|
||||
def get_deployment_presets():
|
||||
"""Get localized deployment presets"""
|
||||
return {
|
||||
i18n.get('openai_preset'): {
|
||||
"extras": ["base", "proxy_openai", "rag", "storage_chromadb", "dbgpts"],
|
||||
"config": "configs/dbgpt-proxy-openai.toml",
|
||||
"description": i18n.get('openai_desc'),
|
||||
"note": i18n.get('openai_note')
|
||||
},
|
||||
i18n.get('deepseek_preset'): {
|
||||
"extras": ["base", "proxy_openai", "rag", "storage_chromadb", "dbgpts"],
|
||||
"config": "configs/dbgpt-proxy-deepseek.toml",
|
||||
"description": i18n.get('deepseek_desc'),
|
||||
"note": i18n.get('deepseek_note')
|
||||
},
|
||||
i18n.get('glm4_preset'): {
|
||||
"extras": ["base", "hf", "cuda121", "rag", "storage_chromadb", "quant_bnb", "dbgpts"],
|
||||
"config": "configs/dbgpt-local-glm.toml",
|
||||
"description": i18n.get('glm4_desc'),
|
||||
"note": i18n.get('glm4_note')
|
||||
},
|
||||
i18n.get('vllm_preset'): {
|
||||
"extras": ["base", "hf", "cuda121", "vllm", "rag", "storage_chromadb", "quant_bnb", "dbgpts"],
|
||||
"config": "configs/dbgpt-local-vllm.toml",
|
||||
"description": i18n.get('vllm_desc'),
|
||||
"note": i18n.get('vllm_note')
|
||||
},
|
||||
i18n.get('llama_cpp_preset'): {
|
||||
"extras": ["base", "hf", "cuda121", "llama_cpp", "rag", "storage_chromadb", "quant_bnb", "dbgpts"],
|
||||
"config": "configs/dbgpt-local-llama-cpp.toml",
|
||||
"description": i18n.get('llama_cpp_desc'),
|
||||
"note": i18n.get('llama_cpp_note')
|
||||
},
|
||||
i18n.get('ollama_preset'): {
|
||||
"extras": ["base", "proxy_ollama", "rag", "storage_chromadb", "dbgpts"],
|
||||
"config": "configs/dbgpt-proxy-ollama.toml",
|
||||
"description": i18n.get('ollama_desc'),
|
||||
"note": i18n.get('ollama_note')
|
||||
},
|
||||
i18n.get('custom_preset'): {
|
||||
"extras": [],
|
||||
"config": "",
|
||||
"description": i18n.get('custom_desc'),
|
||||
"note": i18n.get('custom_note')
|
||||
}
|
||||
}
|
||||
|
||||
@click.group()
|
||||
@click.option('--language', '-l', type=click.Choice(['en', 'zh']), help=I18N().get('language_option'))
|
||||
def cli(language):
|
||||
"""UV Workspace Extras Helper - Manage optional dependencies in UV workspace"""
|
||||
if language:
|
||||
set_language(language)
|
||||
# Update command descriptions to the current language
|
||||
cli.help = i18n.get('cli_description')
|
||||
list_extras.help = i18n.get('list_cmd_description')
|
||||
install_command.help = i18n.get('install_cmd_description')
|
||||
deploy_preset.help = i18n.get('deploy_cmd_description')
|
||||
|
||||
|
||||
@cli.command('list')
|
||||
@click.option('--verbose', '-v', is_flag=True, help=i18n.get('verbose_option'))
|
||||
def list_extras(verbose):
|
||||
"""List all extras in the workspace"""
|
||||
extras = extract_workspace_extras()
|
||||
|
||||
if not extras:
|
||||
click.echo(i18n.get('no_extras_found'))
|
||||
return
|
||||
|
||||
click.echo(i18n.get('extras_in_workspace'))
|
||||
|
||||
for package, info in extras.items():
|
||||
click.echo(click.style(f"📦 {package}", fg="green") +
|
||||
click.style(f" ({os.path.relpath(info['path'])})", fg="blue"))
|
||||
|
||||
if info['extras']:
|
||||
click.echo(f" {i18n.get('available_extras')}")
|
||||
for extra in info['extras']:
|
||||
deps = info['details'][extra]
|
||||
click.echo(f" - {click.style(extra, fg='yellow')}: {len(deps)} {i18n.get('dependencies')}")
|
||||
|
||||
if verbose:
|
||||
for dep in deps:
|
||||
click.echo(f" • {dep}")
|
||||
else:
|
||||
click.echo(f" {i18n.get('no_extras_defined')}")
|
||||
click.echo()
|
||||
|
||||
|
||||
@cli.command('install-cmd')
|
||||
@click.option('--interactive', '-i', is_flag=True, help=i18n.get('interactive_option'))
|
||||
@click.option('--all', 'install_all', is_flag=True, help=i18n.get('all_option'))
|
||||
@click.option('--china', is_flag=True, help=i18n.get('china_option'))
|
||||
@click.argument('package', required=False)
|
||||
@click.argument('extra', required=False)
|
||||
def install_command(interactive, install_all, china, package, extra):
|
||||
"""Generate installation commands for extras"""
|
||||
extras = extract_workspace_extras()
|
||||
|
||||
if not extras:
|
||||
click.echo(i18n.get('no_extras_found'))
|
||||
return
|
||||
|
||||
# Interactive mode
|
||||
if interactive:
|
||||
_interactive_install_guide(extras, china)
|
||||
return
|
||||
|
||||
# Install all extras
|
||||
if install_all:
|
||||
all_extras = []
|
||||
for pkg_info in extras.values():
|
||||
all_extras.extend(pkg_info['extras'])
|
||||
|
||||
if all_extras:
|
||||
cmd = "uv sync --all-packages " + " ".join([f"--extra \"{e}\"" for e in all_extras])
|
||||
if china:
|
||||
cmd += " --index-url=https://pypi.tuna.tsinghua.edu.cn/simple"
|
||||
click.echo(i18n.get('install_all_extras'))
|
||||
click.echo(cmd)
|
||||
else:
|
||||
click.echo(i18n.get('no_extras_found'))
|
||||
return
|
||||
|
||||
# If no package or extra is provided, show all possible installation commands
|
||||
if not package:
|
||||
for pkg, info in extras.items():
|
||||
if info['extras']:
|
||||
for e in info['extras']:
|
||||
cmd = f"uv sync --extra \"{e}\""
|
||||
if china:
|
||||
cmd += " --index-url=https://pypi.tuna.tsinghua.edu.cn/simple"
|
||||
click.echo(i18n.get('install_extras_for').format(pkg, e))
|
||||
click.echo(cmd)
|
||||
click.echo()
|
||||
return
|
||||
|
||||
# Check if the specified package exists
|
||||
if package not in extras:
|
||||
click.echo(i18n.get('package_not_in_workspace').format(package))
|
||||
click.echo(i18n.get('available_packages').format(', '.join(extras.keys())))
|
||||
return
|
||||
|
||||
# If no extra is provided, show all extras for the package
|
||||
if not extra:
|
||||
pkg_extras = extras[package]['extras']
|
||||
if not pkg_extras:
|
||||
click.echo(i18n.get('package_no_extras').format(package))
|
||||
return
|
||||
|
||||
cmd = "uv sync " + " ".join([f"--extra \"{e}\"" for e in pkg_extras])
|
||||
if china:
|
||||
cmd += " --index-url=https://pypi.tuna.tsinghua.edu.cn/simple"
|
||||
click.echo(i18n.get('install_extras_for').format(package, ' '.join(pkg_extras)))
|
||||
click.echo(cmd)
|
||||
return
|
||||
|
||||
# Check if the specified extra exists
|
||||
if extra not in extras[package]['extras']:
|
||||
click.echo(i18n.get('extra_not_in_package').format(extra, package))
|
||||
click.echo(i18n.get('available_extras_in_package').format(', '.join(extras[package]['extras'])))
|
||||
return
|
||||
|
||||
# Show the command to install the specified extra
|
||||
cmd = f"uv sync --extra \"{extra}\""
|
||||
if china:
|
||||
cmd += " --index-url=https://pypi.tuna.tsinghua.edu.cn/simple"
|
||||
click.echo(i18n.get('install_extras_for').format(package, extra))
|
||||
click.echo(cmd)
|
||||
|
||||
|
||||
def _interactive_install_guide(extras: Dict[str, Any], use_china_mirror: bool = False):
|
||||
"""Interactive installation guide"""
|
||||
click.echo(click.style(i18n.get('welcome'), fg="green", bold=True))
|
||||
click.echo(i18n.get('help_message'))
|
||||
|
||||
# Get deployment presets
|
||||
deployment_presets = get_deployment_presets()
|
||||
|
||||
# First step: select installation mode
|
||||
questions = [
|
||||
inquirer.List('preset',
|
||||
message=i18n.get('select_mode'),
|
||||
choices=[(f"{name} - {info['description']}", name) for name, info in deployment_presets.items()],
|
||||
carousel=True)
|
||||
]
|
||||
answers = inquirer.prompt(questions)
|
||||
|
||||
if not answers:
|
||||
return # Operation canceled
|
||||
|
||||
selected_preset = answers['preset']
|
||||
preset_info = deployment_presets[selected_preset]
|
||||
|
||||
# Custom mode: let user select extras
|
||||
if selected_preset == i18n.get('custom_preset'):
|
||||
# Collect all available extras
|
||||
all_available_extras = set()
|
||||
for pkg_info in extras.values():
|
||||
all_available_extras.update(pkg_info["extras"])
|
||||
|
||||
questions = [
|
||||
inquirer.Checkbox('selected_extras',
|
||||
message=i18n.get('select_extras'),
|
||||
choices=sorted(list(all_available_extras)),
|
||||
carousel=True)
|
||||
]
|
||||
answers = inquirer.prompt(questions)
|
||||
|
||||
if not answers or not answers['selected_extras']:
|
||||
click.echo(i18n.get('operation_canceled'))
|
||||
return
|
||||
|
||||
preset_info['extras'] = answers['selected_extras']
|
||||
|
||||
# Show installation information
|
||||
click.echo("\n" + click.style(i18n.get('installation_info'), fg="blue", bold=True))
|
||||
click.echo(f"{i18n.get('selected_mode')} {click.style(selected_preset, fg='green')}")
|
||||
click.echo(f"{i18n.get('description')} {preset_info['description']}")
|
||||
click.echo(f"{i18n.get('note')} {preset_info['note']}")
|
||||
click.echo(f"{i18n.get('will_install')} {', '.join(preset_info['extras'])}")
|
||||
|
||||
if preset_info['config']:
|
||||
click.echo(f"{i18n.get('config_file')} {preset_info['config']}")
|
||||
|
||||
# Confirm installation
|
||||
questions = [
|
||||
inquirer.Confirm('confirm',
|
||||
message=i18n.get('generate_command'),
|
||||
default=True)
|
||||
]
|
||||
answers = inquirer.prompt(questions)
|
||||
|
||||
if not answers or not answers['confirm']:
|
||||
click.echo(i18n.get('operation_canceled'))
|
||||
return
|
||||
|
||||
# Create installation command
|
||||
cmd = "uv sync --all-packages " + " ".join([f"--extra \"{e}\"" for e in preset_info['extras']])
|
||||
if use_china_mirror:
|
||||
cmd += " --index-url=https://pypi.tuna.tsinghua.edu.cn/simple"
|
||||
|
||||
click.echo("\n" + click.style(i18n.get('installation_command'), fg="green", bold=True))
|
||||
click.echo(cmd)
|
||||
|
||||
if preset_info.get('config'):
|
||||
click.echo("\n" + click.style(i18n.get('startup_command'), fg="green", bold=True))
|
||||
click.echo(f"uv run dbgpt start webserver --config {preset_info['config']}")
|
||||
|
||||
# The step to configure the API key or model path
|
||||
if i18n.get('openai_note') in preset_info['note'] or i18n.get('deepseek_note') in preset_info['note']:
|
||||
click.echo("\n" + click.style(i18n.get('further_configuration'), fg="yellow", bold=True))
|
||||
if i18n.get('openai_note') in preset_info['note'] or i18n.get('deepseek_note') in preset_info['note']:
|
||||
click.echo(i18n.get('set_api_key').format(preset_info['config']))
|
||||
elif i18n.get('glm4_note') in preset_info['note'] or i18n.get('vllm_note') in preset_info['note'] or i18n.get('llama_cpp_note') in preset_info['note']:
|
||||
click.echo("\n" + click.style(i18n.get('further_configuration'), fg="yellow", bold=True))
|
||||
if i18n.get('glm4_note') in preset_info['note'] or i18n.get('vllm_note') in preset_info['note'] or i18n.get('llama_cpp_note') in preset_info['note']:
|
||||
click.echo(i18n.get('set_model_path').format(preset_info['config']))
|
||||
|
||||
click.echo("\n" + click.style(f"🎉 {i18n.get('finished')}", fg="green", bold=True))
|
||||
click.echo(i18n.get('copy_command'))
|
||||
click.echo("uv run install_help.py --help")
|
||||
|
||||
|
||||
@cli.command('deploy')
|
||||
@click.option('--preset', '-p', help=i18n.get('preset_option'))
|
||||
@click.option('--china', is_flag=True, help=i18n.get('china_option'))
|
||||
@click.option('--list', 'list_presets', is_flag=True, help=i18n.get('list_presets_option'))
|
||||
def deploy_preset(preset, china, list_presets):
|
||||
"""Use predefined deployment templates"""
|
||||
deployment_presets = get_deployment_presets()
|
||||
|
||||
if list_presets:
|
||||
click.echo(click.style(i18n.get('available_presets'), fg="green", bold=True))
|
||||
for name, info in deployment_presets.items():
|
||||
click.echo(f"\n{click.style(name, fg='yellow', bold=True)}")
|
||||
click.echo(f"{i18n.get('description')} {info['description']}")
|
||||
click.echo(f"{i18n.get('note')} {info['note']}")
|
||||
click.echo(f"Extras: {', '.join(info['extras'])}")
|
||||
if info['config']:
|
||||
click.echo(f"{i18n.get('config_file')} {info['config']}")
|
||||
return
|
||||
|
||||
if not preset:
|
||||
click.echo(i18n.get('specify_preset'))
|
||||
return
|
||||
|
||||
if preset not in deployment_presets:
|
||||
click.echo(i18n.get('preset_not_found').format(preset))
|
||||
click.echo(i18n.get('available_presets_list').format(', '.join(deployment_presets.keys())))
|
||||
return
|
||||
|
||||
preset_info = deployment_presets[preset]
|
||||
|
||||
click.echo(i18n.get('using_preset').format(preset))
|
||||
click.echo(f"{i18n.get('description')} {preset_info['description']}")
|
||||
click.echo(f"{i18n.get('note')} {preset_info['note']}")
|
||||
|
||||
cmd = "uv sync --all-packages " + " ".join([f"--extra \"{e}\"" for e in preset_info['extras']])
|
||||
if china:
|
||||
cmd += " --index-url=https://pypi.tuna.tsinghua.edu.cn/simple"
|
||||
|
||||
click.echo("\n" + click.style(i18n.get('installation_command'), fg="green", bold=True))
|
||||
click.echo(cmd)
|
||||
|
||||
if preset_info.get('config'):
|
||||
click.echo("\n" + click.style(i18n.get('startup_command'), fg="green", bold=True))
|
||||
click.echo(f"uv run dbgpt start webserver --config {preset_info['config']}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli()
|
@ -89,7 +89,6 @@ quant_gptq = [
|
||||
"auto-gptq",
|
||||
]
|
||||
flash_attn = [
|
||||
# "torch>=2.2.1",
|
||||
"dbgpt-acc-flash-attn"
|
||||
]
|
||||
|
||||
@ -118,10 +117,10 @@ conflicts = [
|
||||
]
|
||||
default-groups = ["auto"]
|
||||
|
||||
[[tool.uv.index]]
|
||||
name = "pytorch-cpu"
|
||||
url = "https://download.pytorch.org/whl/cpu"
|
||||
explicit = true
|
||||
# [[tool.uv.index]]
|
||||
# name = "pytorch-cpu"
|
||||
# url = "https://download.pytorch.org/whl/cpu"
|
||||
# explicit = true
|
||||
|
||||
[[tool.uv.index]]
|
||||
name = "pytorch-cu118"
|
||||
@ -151,38 +150,38 @@ explicit = true
|
||||
[tool.uv.sources]
|
||||
torch = [
|
||||
# MacOS support CPU only
|
||||
{ index = "pytorch-cpu", marker = "platform_system == 'Darwin'" },
|
||||
# { index = "pytorch-cpu", marker = "platform_system == 'Darwin'" },
|
||||
# Windows use CPU or CUDA
|
||||
{ index = "pytorch-cpu", marker = "platform_system == 'Windows'", extra="cpu"},
|
||||
# { index = "pytorch-cpu", marker = "platform_system == 'Windows'", extra="cpu"},
|
||||
{ index = "pytorch-cu118", marker = "platform_system == 'Windows'", extra = "cuda118" },
|
||||
{ index = "pytorch-cu121", marker = "platform_system == 'Windows'", extra = "cuda121" },
|
||||
{ index = "pytorch-cu124", marker = "platform_system == 'Windows'", extra = "cuda124" },
|
||||
# Linux support all versions
|
||||
{ index = "pytorch-cpu", marker = "platform_system == 'Linux'", extra = "cpu" },
|
||||
# { index = "pytorch-cpu", marker = "platform_system == 'Linux'", extra = "cpu" },
|
||||
{ index = "pytorch-cu118", marker = "platform_system == 'Linux'", extra = "cuda118" },
|
||||
{ index = "pytorch-cu121", marker = "platform_system == 'Linux'", extra = "cuda121" },
|
||||
{ index = "pytorch-cu124", marker = "platform_system == 'Linux'", extra = "cuda124" },
|
||||
# { index = "pytorch-rocm60", marker = "platform_system == 'Linux'", extra = "rocm60" },
|
||||
]
|
||||
torchvision = [
|
||||
{ index = "pytorch-cpu", marker = "platform_system == 'Darwin'" },
|
||||
{ index = "pytorch-cpu", marker = "platform_system == 'Windows'", extra = "cpu" },
|
||||
# { index = "pytorch-cpu", marker = "platform_system == 'Darwin'" },
|
||||
# { index = "pytorch-cpu", marker = "platform_system == 'Windows'", extra = "cpu" },
|
||||
{ index = "pytorch-cu118", marker = "platform_system == 'Windows'", extra = "cuda118" },
|
||||
{ index = "pytorch-cu121", marker = "platform_system == 'Windows'", extra = "cuda121" },
|
||||
{ index = "pytorch-cu124", marker = "platform_system == 'Windows'", extra = "cuda124" },
|
||||
{ index = "pytorch-cpu", marker = "platform_system == 'Linux'", extra = "cpu" },
|
||||
# { index = "pytorch-cpu", marker = "platform_system == 'Linux'", extra = "cpu" },
|
||||
{ index = "pytorch-cu118", marker = "platform_system == 'Linux'", extra = "cuda118" },
|
||||
{ index = "pytorch-cu121", marker = "platform_system == 'Linux'", extra = "cuda121" },
|
||||
{ index = "pytorch-cu124", marker = "platform_system == 'Linux'", extra = "cuda124" },
|
||||
# { index = "pytorch-rocm60", marker = "platform_system == 'Linux'", extra = "rocm60" },
|
||||
]
|
||||
torchaudio = [
|
||||
{ index = "pytorch-cpu", marker = "platform_system == 'Darwin'" },
|
||||
{ index = "pytorch-cpu", marker = "platform_system == 'Windows'", extra = "cpu" },
|
||||
# { index = "pytorch-cpu", marker = "platform_system == 'Darwin'" },
|
||||
# { index = "pytorch-cpu", marker = "platform_system == 'Windows'", extra = "cpu" },
|
||||
{ index = "pytorch-cu118", marker = "platform_system == 'Windows'", extra = "cuda118" },
|
||||
{ index = "pytorch-cu121", marker = "platform_system == 'Windows'", extra = "cuda121" },
|
||||
{ index = "pytorch-cu124", marker = "platform_system == 'Windows'", extra = "cuda124" },
|
||||
{ index = "pytorch-cpu", marker = "platform_system == 'Linux'", extra = "cpu" },
|
||||
# { index = "pytorch-cpu", marker = "platform_system == 'Linux'", extra = "cpu" },
|
||||
{ index = "pytorch-cu118", marker = "platform_system == 'Linux'", extra = "cuda118" },
|
||||
{ index = "pytorch-cu121", marker = "platform_system == 'Linux'", extra = "cuda121" },
|
||||
{ index = "pytorch-cu124", marker = "platform_system == 'Linux'", extra = "cuda124" },
|
||||
|
@ -254,7 +254,7 @@ class ServiceConfig(BaseParameters):
|
||||
|
||||
|
||||
@dataclass
|
||||
class ApplicationConfig:
|
||||
class ApplicationConfig(BaseParameters):
|
||||
"""Application configuration."""
|
||||
|
||||
hooks: List[HookConfig] = field(
|
||||
|
@ -112,7 +112,7 @@ def initialize_app(param: ApplicationConfig, args: List[str] = None):
|
||||
If you use gunicorn as a process manager, initialize_app can be invoke in
|
||||
`on_starting` hook.
|
||||
Args:
|
||||
param:WebWerverParameters
|
||||
param:WebServerParameters
|
||||
args:List[str]
|
||||
"""
|
||||
|
||||
@ -126,7 +126,6 @@ def initialize_app(param: ApplicationConfig, args: List[str] = None):
|
||||
log_config,
|
||||
default_logger_filename=os.path.join(LOGDIR, "dbgpt_webserver.log"),
|
||||
)
|
||||
print(param)
|
||||
|
||||
server_init(param, system_app)
|
||||
mount_routers(app)
|
||||
|
@ -88,12 +88,12 @@ def _initialize_openai_v1(init_params: OpenAIParameters):
|
||||
|
||||
if api_key is None:
|
||||
raise ValueError("api_key is required, please set OPENAI_API_KEY environment")
|
||||
if base_url is None:
|
||||
raise ValueError("base_url is required, please set OPENAI_BASE_URL environment")
|
||||
if base_url.endswith("/"):
|
||||
if base_url and base_url.endswith("/"):
|
||||
base_url = base_url[:-1]
|
||||
|
||||
openai_params = {"api_key": api_key, "base_url": base_url}
|
||||
openai_params = {"api_key": api_key}
|
||||
if base_url:
|
||||
openai_params["base_url"] = base_url
|
||||
return openai_params, api_type, api_version, api_azure_deployment
|
||||
|
||||
|
||||
|
@ -55,7 +55,7 @@ def _get_current_cuda_memory() -> List[GPUInfo]:
|
||||
try:
|
||||
import torch
|
||||
except ImportError:
|
||||
logger.warn("Torch not installed")
|
||||
logger.debug("Torch not installed")
|
||||
return []
|
||||
if torch.cuda.is_available():
|
||||
num_gpus = torch.cuda.device_count()
|
||||
@ -80,5 +80,5 @@ def _get_current_cuda_memory() -> List[GPUInfo]:
|
||||
)
|
||||
return gpu_infos
|
||||
else:
|
||||
logger.warn("CUDA is not available.")
|
||||
logger.debug("CUDA is not available.")
|
||||
return []
|
||||
|
@ -33,7 +33,6 @@ rag = [
|
||||
"python-docx",
|
||||
"pypdf",
|
||||
"pdfplumber",
|
||||
"sentence-transformers",
|
||||
]
|
||||
graph_rag = [
|
||||
# For visualization in code
|
||||
|
Loading…
Reference in New Issue
Block a user