-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
137 changed files
with
5,164 additions
and
3,421 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
# Base Image | ||
FROM python:3.11 | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y libgl1-mesa-glx | ||
|
||
RUN mkdir /Langchain-Chatchat | ||
COPY requirements.txt /Langchain-Chatchat | ||
COPY requirements_api.txt /Langchain-Chatchat | ||
COPY requirements_webui.txt /Langchain-Chatchat | ||
|
||
WORKDIR /Langchain-Chatchat | ||
RUN pip install --upgrade pip | ||
RUN pip install -r requirements.txt | ||
RUN pip install -r requirements_api.txt | ||
RUN pip install -r requirements_webui.txt | ||
|
||
EXPOSE 8501 | ||
EXPOSE 7861 | ||
EXPOSE 20000 | ||
# Labels | ||
LABEL maintainer=chatchat | ||
# Environment Variables | ||
ENV HOME=/usr/local/lib/python3.11/site-packages/chatchat | ||
# Init Environment | ||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ | ||
echo "Asia/Shanghai" > /etc/timezone | ||
# Install Dependencies | ||
RUN apt-get update -y && \ | ||
apt-get install -y --no-install-recommends libgl1 libglib2.0-0 && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
RUN pip install openpyxl networkx faiss-cpu jq unstructured[pdf] \ | ||
opencv-python rapidocr-onnxruntime PyMuPDF rank_bm25 youtube_search python-docx | ||
# Install Chatchat | ||
RUN pip install --index-url https://pypi.python.org/simple/ langchain-chatchat -U | ||
# Install ModelProvider | ||
RUN pip install xinference-client | ||
# Make Custom Settings | ||
RUN chatchat-config server --default_bind_host=0.0.0.0 && \ | ||
chatchat-config model --default_llm_model qwen2-instruct | ||
# Copy Data | ||
COPY /libs/chatchat-server/chatchat/configs/model_providers.yaml $HOME/configs/model_providers.yaml | ||
ADD /docker/data.tar.gz $HOME/ | ||
WORKDIR $HOME | ||
EXPOSE 7861 8501 | ||
ENTRYPOINT ["chatchat", "-a"] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
version: '3.9' | ||
services: | ||
xinference: | ||
image: xprobe/xinference:v0.12.1 | ||
restart: always | ||
command: xinference-local -H 0.0.0.0 | ||
# ports: # 不使用 host network 时可打开. | ||
# - "9997:9997" | ||
network_mode: "host" | ||
# 将本地路径(~/xinference)挂载到容器路径(/root/.xinference)中, | ||
# 详情见: https://inference.readthedocs.io/zh-cn/latest/getting_started/using_docker_image.html | ||
volumes: | ||
- ~/xinference:/root/.xinference | ||
# - ~/xinference/cache/huggingface:/root/.cache/huggingface | ||
# - ~/xinference/cache/modelscope:/root/.cache/modelscope | ||
deploy: | ||
resources: | ||
reservations: | ||
devices: | ||
- driver: nvidia | ||
count: all | ||
capabilities: [gpu] | ||
runtime: nvidia | ||
# 模型源更改为 ModelScope, 默认为 HuggingFace | ||
# environment: | ||
# - XINFERENCE_MODEL_SRC=modelscope | ||
chatchat: | ||
image: chatimage/chatchat:0.3.0-0623-3 | ||
restart: always | ||
# ports: # 不使用 host network 时可打开. | ||
# - "7861:7861" | ||
# - "8501:8501" | ||
network_mode: "host" | ||
# 将本地路径(~/chatchat/data)挂载到容器默认数据路径(/usr/local/lib/python3.11/site-packages/chatchat/data)中 | ||
# 将本地模型接入配置文件(~/chatchat/model_providers.yaml)挂载到容器默认模型接入配置文件路径(/usr/local/lib/python3.11/site-packages/chatchat/configs/)中 | ||
# volumes: | ||
# - ~/chatchat/data:/usr/local/lib/python3.11/site-packages/chatchat/data | ||
# - ~/chatchat/model_providers.yaml:/usr/local/lib/python3.11/site-packages/chatchat/configs/model_providers.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
### chatchat 容器化部署指引 | ||
|
||
> 提示: 此指引为在 Linux 环境下编写完成, 其他环境下暂未测试, 理论上可行. | ||
> | ||
> Langchain-Chatchat docker 镜像已支持多架构, 欢迎大家自行测试. | ||
#### 一. Langchain-Chatchat 体验部署 | ||
|
||
##### 1. 安装 docker-compose | ||
寻找适合你环境的 docker-compose 版本, 请参考 [Docker-Compose](https://github.com/docker/compose). | ||
|
||
举例: Linux X86 环境 可下载 [docker-compose-linux-x86_64](https://github.com/docker/compose/releases/download/v2.27.3/docker-compose-linux-x86_64) 使用. | ||
```shell | ||
cd ~ | ||
wget https://github.com/docker/compose/releases/download/v2.27.3/docker-compose-linux-x86_64 | ||
mv docker-compose-linux-x86_64 /usr/bin/docker-compose | ||
which docker-compose | ||
``` | ||
/usr/bin/docker-compose | ||
```shell | ||
docker-compose -v | ||
``` | ||
Docker Compose version v2.27.3 | ||
|
||
##### 2. 安装 NVIDIA Container Toolkit | ||
寻找适合你环境的 NVIDIA Container Toolkit 版本, 请参考: [Installing the NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html). | ||
|
||
安装完成后记得按照刚刚文档中`Configuring Docker`章节对 docker 进行初始化. | ||
|
||
##### 3. 创建 xinference 数据缓存路径 | ||
|
||
这一步强烈建议, 因为可以将 xinference 缓存的模型都保存到本地, 长期使用. | ||
```shell | ||
mkdir -p ~/xinference | ||
``` | ||
|
||
##### 4. 下载 chatchat & xinference 启动配置文件(docker-compose.yaml) | ||
```shell | ||
cd ~ | ||
wget https://github.com/chatchat-space/Langchain-Chatchat/blob/master/docker/docker-compose.yaml | ||
``` | ||
|
||
##### 5. 启动 chatchat & xinference 服务 | ||
```shell | ||
docker-compose up -d | ||
``` | ||
出现如下日志即为成功 ( 第一次启动需要下载 docker 镜像, 时间较长, 这里已经提前下载好了 ) | ||
```text | ||
WARN[0000] /root/docker-compose.yaml: `version` is obsolete | ||
[+] Running 2/2 | ||
✔ Container root-chatchat-1 Started 0.2s | ||
✔ Container root-xinference-1 Started 0.3s | ||
``` | ||
|
||
##### 6.检查服务启动情况 | ||
```shell | ||
docker-compose up -d | ||
``` | ||
```text | ||
WARN[0000] /root/docker-compose.yaml: `version` is obsolete | ||
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS | ||
root-chatchat-1 chatimage/chatchat:0.3.0-0622 "chatchat -a" chatchat 3 minutes ago Up 3 minutes | ||
root-xinference-1 xprobe/xinference:v0.12.1 "/opt/nvidia/nvidia_…" xinference 3 minutes ago Up 3 minutes | ||
``` | ||
```shell | ||
ss -anptl | grep -E '(8501|7861|9997)' | ||
``` | ||
```text | ||
LISTEN 0 128 0.0.0.0:9997 0.0.0.0:* users:(("pt_main_thread",pid=1489804,fd=21)) | ||
LISTEN 0 128 0.0.0.0:8501 0.0.0.0:* users:(("python",pid=1490078,fd=10)) | ||
LISTEN 0 128 0.0.0.0:7861 0.0.0.0:* users:(("python",pid=1490014,fd=9)) | ||
``` | ||
如上, 服务均已正常启动, 即可体验使用. | ||
|
||
> 提示: 先登陆 xinference ui `http://<your_ip>:9997` 启动 llm 和 embedding 后, 再登陆 chatchat ui `http://<your_ip>:8501` 进行体验. | ||
> | ||
> 详细文档: | ||
> - Langchain-chatchat 使用请参考: [LangChain-Chatchat](/README.md) | ||
> | ||
> - Xinference 使用请参考: [欢迎来到 Xinference!](https://inference.readthedocs.io/zh-cn/latest/index.html) | ||
#### 二. Langchain-Chatchat 进阶部署 | ||
|
||
##### 1. 按照 `Langchain-Chatchat 体验部署` 内容顺序依次完成 | ||
|
||
##### 2. 创建 chatchat 数据缓存路径 | ||
```shell | ||
cd ~ | ||
mkdir -p ~/chatchat | ||
``` | ||
|
||
##### 3. 修改 `docker-compose.yaml` 文件内容 | ||
|
||
原文件内容: | ||
```yaml | ||
(上文 ...) | ||
chatchat: | ||
image: chatimage/chatchat:0.3.0-0622 | ||
(省略 ...) | ||
# 将本地路径(~/chatchat/data)挂载到容器默认数据路径(/usr/local/lib/python3.11/site-packages/chatchat/data)中 | ||
# 将本地模型接入配置文件(~/chatchat/model_providers.yaml)挂载到容器默认模型接入配置文件路径(/usr/local/lib/python3.11/site-packages/chatchat/configs/)中 | ||
# volumes: | ||
# - ~/chatchat/data:/usr/local/lib/python3.11/site-packages/chatchat/data | ||
# - ~/chatchat/model_providers.yaml:/usr/local/lib/python3.11/site-packages/chatchat/configs/model_providers.yaml | ||
(下文 ...) | ||
``` | ||
将 `volumes` 字段注释打开, 并按照 `YAML` 格式对齐, 如下: | ||
```yaml | ||
(上文 ...) | ||
chatchat: | ||
image: chatimage/chatchat:0.3.0-0622 | ||
(省略 ...) | ||
# 将本地路径(~/chatchat/data)挂载到容器默认数据路径(/usr/local/lib/python3.11/site-packages/chatchat/data)中 | ||
# 将本地模型接入配置文件(~/chatchat/model_providers.yaml)挂载到容器默认模型接入配置文件路径(/usr/local/lib/python3.11/site-packages/chatchat/configs/)中 | ||
volumes: | ||
- ~/chatchat/data:/usr/local/lib/python3.11/site-packages/chatchat/data | ||
- ~/chatchat/model_providers.yaml:/usr/local/lib/python3.11/site-packages/chatchat/configs/model_providers.yaml | ||
(下文 ...) | ||
``` | ||
|
||
##### 4. 下载数据库初始文件 | ||
|
||
> 提示: 这里的 `data.tar.gz` 文件仅包含初始化后的数据库 `samples` 文件一份及相应目录结构, 用户可将原先数据和目录结构迁移此处. | ||
> > [!WARNING] 请您先备份好您的数据再进行迁移!!! | ||
```shell | ||
cd ~/chatchat | ||
wget https://github.com/chatchat-space/Langchain-Chatchat/blob/master/docker/data.tar.gz | ||
tar -xvf data.tar.gz | ||
``` | ||
```shell | ||
cd data | ||
pwd | ||
``` | ||
/root/chatchat/data | ||
```shell | ||
ls -l | ||
``` | ||
```text | ||
total 20 | ||
drwxr-xr-x 3 root root 4096 Jun 22 10:46 knowledge_base | ||
drwxr-xr-x 18 root root 4096 Jun 22 10:52 logs | ||
drwxr-xr-x 5 root root 4096 Jun 22 10:46 media | ||
drwxr-xr-x 5 root root 4096 Jun 22 10:46 nltk_data | ||
drwxr-xr-x 3 root root 4096 Jun 22 10:46 temp | ||
``` | ||
|
||
##### 5. 下载 `model_providers.yaml` 配置文件 | ||
> 提示: 后续可以自定义本地路径下的 `model_providers.yaml` 来实现`自定义模型接入配置` | ||
```shell | ||
cd ~/chatchat | ||
wget https://github.com/chatchat-space/Langchain-Chatchat/blob/master/libs/model-providers/model_providers.yaml | ||
``` | ||
|
||
##### 6. 重启 chatchat 服务 | ||
|
||
这一步需要到 `docker-compose.yaml` 文件所在路径下执行, 即: | ||
```shell | ||
cd ~ | ||
docker-compose down chatchat | ||
docker-compose up -d chatchat | ||
``` | ||
操作及检查结果如下: | ||
```text | ||
[root@VM-2-15-centos ~]# docker-compose down chatchat | ||
WARN[0000] /root/docker-compose.yaml: `version` is obsolete | ||
[+] Running 1/1 | ||
✔ Container root-chatchat-1 Removed 0.5s | ||
[root@VM-2-15-centos ~]# docker-compose up -d | ||
WARN[0000] /root/docker-compose.yaml: `version` is obsolete | ||
[+] Running 2/2 | ||
✔ Container root-xinference-1 Running 0.0s | ||
✔ Container root-chatchat-1 Started 0.2s | ||
[root@VM-2-15-centos ~]# docker-compose ps | ||
WARN[0000] /root/docker-compose.yaml: `version` is obsolete | ||
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS | ||
root-chatchat-1 chatimage/chatchat:0.3.0-0622 "chatchat -a" chatchat 33 seconds ago Up 32 seconds | ||
root-xinference-1 xprobe/xinference:v0.12.1 "/opt/nvidia/nvidia_…" xinference 45 minutes ago Up 45 minutes | ||
[root@VM-2-15-centos ~]# ss -anptl | grep -E '(8501|7861|9997)' | ||
LISTEN 0 128 0.0.0.0:9997 0.0.0.0:* users:(("pt_main_thread",pid=1489804,fd=21)) | ||
LISTEN 0 128 0.0.0.0:8501 0.0.0.0:* users:(("python",pid=1515944,fd=10)) | ||
LISTEN 0 128 0.0.0.0:7861 0.0.0.0:* users:(("python",pid=1515878,fd=9)) | ||
``` |
Oops, something went wrong.