GitHub地址:https://github.com/chatchat-space/Langchain-Chatchat

1.创建虚拟环境

#创建环境
conda create --name langchain python=3.11.7
#激活环境
conda activate langchain

MAC 部署Langchain-chatchat(2.x)_Langchain-chatchat

2.安装依赖

#拉取仓库 
git clone https://github.com/chatchat-space/Langchain-Chatchat.git 
#进入目录
cd Langchain-Chatchat 
#安装torch
pip3 install torch torchvision torchaudio -i https://pypi.tuna.tsinghua.edu.cn/simple/


#安装brew
  /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
#特殊方式安装xformers
brew install llvm libomp
# 在项目环境中执行以下
export CC=/opt/homebrew/opt/llvm/bin/clang 
export CXX=/opt/homebrew/opt/llvm/bin/clang++
export LDFLAGS="-L/opt/homebrew/opt/libomp/lib" 
export CPPFLAGS="-I/opt/homebrew/opt/libomp/include"

#安装项目依赖 
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/

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

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

#安装依赖
pip install langchain fastapi langchain_community chardet fastchat jwt nltk -i https://pypi.tuna.tsinghua.edu.cn/simple/

xformers报错演示

MAC 部署Langchain-chatchat(2.x)_Langchain-chatchat_02

3.下载模型

#安装lfs
brew install git-lfs
#创建文件夹THUDM和BAAI
#安装模型放入Qwen文件夹内
git lfs clone https://www.modelscope.cn/qwen/Qwen1.5-7B-Chat.git
#安装模型放入BAAI文件夹内
git lfs clone lfs https://huggingface.co/BAAI/bge-large-zh

MAC 部署Langchain-chatchat(2.x)_github_03

4.初始化知识库和配置文件

#从移动硬盘复制模型文件知识库文件
BAALI文件和THUDM文件和 knowledge_base文件

#初始化知识库
python copy_config_example.py
python init_database.py --recreate-vs

MAC 部署Langchain-chatchat(2.x)_github_04

5.一键启动

修改用GPU运行

MAC 部署Langchain-chatchat(2.x)_Langchain-chatchat_05

修改端口

MAC 部署Langchain-chatchat(2.x)_github_06

修改模型配置

model_config.py文件

LLM_MODELS = ["chatglm3-6b", "zhipu-api", "openai-api"]

修改为

LLM_MODELS = ["Qwen1.5-7B-Chat"]

启动项目

python startup.py -a

web页面

http://192.168.96.31:50002/