赞
踩
目录
从0.3.1开始,模型与项目独立部署,需要借助xinference、oneai、localai等平台独立部署大模型,
Langchain-Chat通过接口API调用
功能 | 0.2.x | 0.3.x |
---|---|---|
模型接入 | 本地:fastchat 在线:XXXModelWorker | 本地:model_provider,支持大部分主流模型加载框架 在线:oneapi 所有模型接入均兼容openai sdk |
Agent | ❌不稳定 | ✅针对ChatGLM3和QWen进行优化,Agent能力显著提升 |
LLM对话 | ✅ | ✅ |
知识库对话 | ✅ | ✅ |
搜索引擎对话 | ✅ | ✅ |
文件对话 | ✅仅向量检索 | ✅统一为File RAG功能,支持BM25+KNN等多种检索方式 |
数据库对话 | ❌ | ✅ |
多模态图片对话 | ❌ | ✅ 推荐使用 qwen-vl-chat |
ARXIV文献对话 | ❌ | ✅ |
Wolfram对话 | ❌ | ✅ |
文生图 | ❌ | ✅ |
本地知识库管理 | ✅ | ✅ |
WEBUI | ✅ | ✅更好的多会话支持,自定义系统提示词... |
Langchain-Chatchat 自 0.3.0 版本起,为方便支持用户使用 pip 方式安装部署,以及为避免环境中依赖包版本冲突等问题, 在源代码/开发部署中不再继续使用 requirements.txt 管理项目依赖库,转为使用 Poetry 进行环境管理。
1)pip 安装:
pip install langchain-chatchat -U
2)docker安装
docker pull chatimage/chatchat:0.3.1.3-0f4eb00-20240729
# 国内镜像
docker pull ccr.ccs.tencentyun.com/langchain-chatchat/chatchat:0.3.1.3-0f4eb00-20240729
git clone https://github.com/chatchat-space/Langchain-Chatchat.git
- conda create -n chat03x python=3.10
-
- conda activate chat03x
- pip install poetry
-
- poetry config virtualenvs.prefer-active-python true
-
- cd Langchain-Chatchat-03x/libs/chatchat-server
-
- poetry install --with lint,test -E xinference
-
-
- pip install -e .
Poetry install 后会在你的虚拟环境中 site-packages 路径下生成一个 chatchat-
<version>
.dist-info 文件夹带有 direct_url.json 文件,这个文件指向你的开发环境
- cd libs/chatchat-server
-
- python chatchat/cli.py init
注:配置参数打印查看
- from chatchat.settings import Settings
-
- print(Settings.basic_settings) # 基本配置信息,包括数据目录、服务器配置等
- print(Settings.kb_settings) # 知识库相关配置项
- print(Settings.model_settings) # 模型相关配置项
- print(Settings.tool_settings) # 工具相关配置项
- print(Settings.prompt_settings) # prompt 模板
修改model_settings.yaml 文件
- cd libs/chatchat-server
-
- vim model_settings.yaml
- # 默认选用的 LLM 名称
- DEFAULT_LLM_MODEL: llama3-8b
-
- # 默认选用的 Embedding 名称
- DEFAULT_EMBEDDING_MODEL: bge-large-zh-v1.5 #bge-m3
-
-
- # # 平台类型
- # # 可选值:['xinference', 'ollama', 'oneapi', 'fastchat', 'openai', 'custom openai']
- platform_type: xinference
-
- # # xinference 平台访问地址 api url
- api_base_url: http://127.0.0.1:9997/v1
-
- # # api key if available
- api_key: EMPTY

博主已搭建xinference平台, 并启动 名为llama3-8b的模型、以及名为 customer-bge-large-zh的embedding
可以借助平台,在线下载部署
需要启动语言模型与嵌入模型
- cd libs/chatchat-server
-
- # 会清空数据库、删除已有的配置文件,如果有重要数据,请备份。
- python chatchat/cli.py kb --recreate-vs
如需使用其它 Embedding 模型,或者重建特定的知识库,请查看 python chatchat/cli.py kb --help
了解更多的参数。
需要先确保LLM 模型启动成功,参考【LLM】-13-Xinference的部署、使用-CSDN博客
- cd libs/chatchat-server
-
- python chatchat/cli.py start -a
部分启动日志
操作系统:Linux-5.15.0-73-generic-x86_64-with-glibc2.31.
python版本:3.10.14 (main, May 6 2024, 19:42:50) [GCC 11.2.0]
项目版本:0.3.1.3
langchain版本:0.1.17
数据目录:/home/chatchat/Langchain-Chatchat-03x/libs/chatchat-server
当前使用的分词器:ChineseRecursiveTextSplitter
默认选用的 Embedding 名称: customer-bge-large-zh
- # 服务器基本配置信息
- # 除 log_verbose/HTTPX_DEFAULT_TIMEOUT 修改后即时生效
- # 其它配置项修改后都需要重启服务器才能生效,服务运行期间请勿修改
-
-
- # 生成该配置模板的项目代码版本,如这里的值与程序实际版本不一致,建议重建配置文件模板
- version: 0.3.1.3
-
- # 是否开启日志详细信息
- log_verbose: false
-
- # httpx 请求默认超时时间(秒)。如果加载模型或对话较慢,出现超时错误,可以适当加大该值。
- HTTPX_DEFAULT_TIMEOUT: 300.0
-
- # 知识库默认存储路径
- KB_ROOT_PATH: /home/chatchat/Langchain-Chatchat-03x/libs/chatchat-server/data/knowledge_base
-
- # 数据库默认存储路径。如果使用sqlite,可以直接修改DB_ROOT_PATH;如果使用其它数据库,请直接修改SQLALCHEMY_DATABASE_URI。
- DB_ROOT_PATH:
- /home/chatchat/Langchain-Chatchat-03x/libs/chatchat-server/data/knowledge_base/info.db
-
- # 知识库信息数据库连接URI
- SQLALCHEMY_DATABASE_URI:
- sqlite:home/chatchat/Langchain-Chatchat-03x/libs/chatchat-server/data/knowledge_base/info.db
-
- # API 是否开启跨域
- OPEN_CROSS_DOMAIN: false
-
- # 各服务器默认绑定host。如改为"0.0.0.0"需要修改下方所有XX_SERVER的host
- # Windows 下 WEBUI 自动弹出浏览器时,如果地址为 "0.0.0.0" 是无法访问的,需要手动修改地址栏
- DEFAULT_BIND_HOST: 0.0.0.0
-
- # API 服务器地址。其中 public_host 用于生成云服务公网访问链接(如知识库文档链接)
- API_SERVER:
- host: 0.0.0.0
- port: 7861
- public_host: 127.0.0.1
- public_port: 7861
-
- # WEBUI 服务器地址
- WEBUI_SERVER:
- host: 0.0.0.0
- port: 8501

参考文章:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。