merge from master
This commit is contained in:
commit
5cccd5e7aa
10
README.md
10
README.md
|
|
@ -59,7 +59,7 @@ docker run -d --gpus all -p 80:8501 registry.cn-beijing.aliyuncs.com/chatchat/ch
|
|||
该项目是一个可以实现 __完全本地化__推理的知识库增强方案, 重点解决数据安全保护,私域化部署的企业痛点。
|
||||
本开源方案采用```Apache License```,可以免费商用,无需付费。
|
||||
|
||||
我们支持市面上主流的本地大预言模型和Embedding模型,支持开源的本地向量数据库。
|
||||
我们支持市面上主流的本地大语言模型和Embedding模型,支持开源的本地向量数据库。
|
||||
支持列表详见[Wiki](https://github.com/chatchat-space/Langchain-Chatchat/wiki/)
|
||||
|
||||
|
||||
|
|
@ -92,14 +92,14 @@ $ pip install -r requirements_webui.txt
|
|||
|
||||
如需在本地或离线环境下运行本项目,需要首先将项目所需的模型下载至本地,通常开源 LLM 与 Embedding 模型可以从 [HuggingFace](https://huggingface.co/models) 下载。
|
||||
|
||||
以本项目中默认使用的 LLM 模型 [THUDM/ChatGLM2-6B](https://huggingface.co/THUDM/chatglm2-6b) 与 Embedding 模型 [moka-ai/m3e-base](https://huggingface.co/moka-ai/m3e-base) 为例:
|
||||
以本项目中默认使用的 LLM 模型 [THUDM/ChatGLM3-6B](https://huggingface.co/THUDM/chatglm3-6b) 与 Embedding 模型 [BAAI/bge-large-zh](https://huggingface.co/BAAI/bge-large-zh) 为例:
|
||||
|
||||
下载模型需要先[安装 Git LFS](https://docs.github.com/zh/repositories/working-with-files/managing-large-files/installing-git-large-file-storage),然后运行
|
||||
|
||||
```Shell
|
||||
$ git lfs install
|
||||
$ git clone https://huggingface.co/THUDM/chatglm2-6b
|
||||
$ git clone https://huggingface.co/moka-ai/m3e-base
|
||||
$ git clone https://huggingface.co/THUDM/chatglm3-6b
|
||||
$ git clone https://huggingface.co/BAAI/bge-large-zh
|
||||
```
|
||||
### 3. 初始化知识库和配置文件
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ $ python startup.py -a
|
|||
[](https://t.me/+RjliQ3jnJ1YyN2E9)
|
||||
|
||||
### 项目交流群
|
||||
<img src="img/qr_code_76.jpg" alt="二维码" width="300" />
|
||||
<img src="img/qr_code_82.jpg" alt="二维码" width="300" />
|
||||
|
||||
🎉 Langchain-Chatchat 项目微信交流群,如果你也对本项目感兴趣,欢迎加入群聊参与讨论交流。
|
||||
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ ONLINE_LLM_MODEL = {
|
|||
"version": "qwen-turbo", # 可选包括 "qwen-turbo", "qwen-plus"
|
||||
"api_key": "", # 请在阿里云控制台模型服务灵积API-KEY管理页面创建
|
||||
"provider": "QwenWorker",
|
||||
"embed_model": "text-embedding-v1" # embedding 模型名称
|
||||
},
|
||||
|
||||
# 百川 API,申请方式请参考 https://www.baichuan-ai.com/home#api-enter
|
||||
|
|
@ -241,7 +242,7 @@ MODEL_PATH = {
|
|||
"agentlm-13b": "THUDM/agentlm-13b",
|
||||
"agentlm-70b": "THUDM/agentlm-70b",
|
||||
|
||||
"Yi-34B-Chat": "https://huggingface.co/01-ai/Yi-34B-Chat",
|
||||
"Yi-34B-Chat": "01-ai/Yi-34B-Chat",
|
||||
},
|
||||
"reranker":{
|
||||
"bge-reranker-large":"BAAI/bge-reranker-large",
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 156 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 170 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 272 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 224 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 192 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 266 KiB |
|
|
@ -1 +1 @@
|
|||
Subproject commit 4c6f1a9748563b5d3ae81a628ff8a71f3e5686d1
|
||||
Subproject commit 2f24adb218f23eab00d7fcd7ccf5072f2f35cb3c
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
# API requirements
|
||||
|
||||
# On Windows system, install the cuda version manually from https://pytorch.org/
|
||||
torch>=2.1.2
|
||||
torchvision>=0.16.2
|
||||
torchaudio>=2.1.2
|
||||
torch~=2.1.2
|
||||
torchvision~=0.16.2
|
||||
torchaudio~=2.1.2
|
||||
|
||||
langchain>=0.0.352
|
||||
langchain-experimental>=0.0.47
|
||||
langchain==0.0.352
|
||||
langchain-experimental==0.0.47
|
||||
pydantic==1.10.13
|
||||
fschat>=0.2.33
|
||||
xformers>=0.0.23.post1
|
||||
openai>=1.6.0
|
||||
sentence_transformers>=2.2.2
|
||||
transformers>=4.36.2
|
||||
fschat==0.2.34
|
||||
xformers==0.0.23.post1
|
||||
openai~=1.6.0
|
||||
sentence_transformers==2.2.2
|
||||
transformers==4.36.2
|
||||
fastapi>=0.105
|
||||
nltk>=3.8.1
|
||||
uvicorn>=0.24.0.post1
|
||||
|
|
@ -20,11 +20,11 @@ starlette~=0.27.0
|
|||
unstructured[all-docs]==0.11.0
|
||||
python-magic-bin; sys_platform == 'win32'
|
||||
SQLAlchemy==2.0.19
|
||||
faiss-cpu>=1.7.4
|
||||
accelerate>=0.24.1
|
||||
spacy>=3.7.2
|
||||
PyMuPDF>=1.23.8
|
||||
rapidocr_onnxruntime>=1.3.8
|
||||
faiss-cpu~=1.7.4
|
||||
accelerate==0.24.1
|
||||
spacy~=3.7.2
|
||||
PyMuPDF~=1.23.8
|
||||
rapidocr_onnxruntime~=1.3.8
|
||||
requests>=2.31.0
|
||||
pathlib>=1.0.1
|
||||
pytest>=7.4.3
|
||||
|
|
@ -37,20 +37,20 @@ websockets>=12.0
|
|||
numpy~=1.26.2
|
||||
pandas~=2.1.4
|
||||
einops>=0.7.0
|
||||
transformers_stream_generator>=0.0.4
|
||||
vllm>=0.2.6; sys_platform == "linux"
|
||||
transformers_stream_generator==0.0.4
|
||||
vllm==0.2.6; sys_platform == "linux"
|
||||
|
||||
# optional document loaders
|
||||
|
||||
rapidocr_paddle[gpu]>=1.3.0.post5
|
||||
jq>=1.6.0
|
||||
html2text
|
||||
beautifulsoup4>=4.12.2
|
||||
pysrt>=1.1.2
|
||||
beautifulsoup4~=4.12.2
|
||||
pysrt~=1.1.2
|
||||
|
||||
# Online api libs dependencies
|
||||
|
||||
zhipuai>=1.0.7
|
||||
zhipuai>=1.0.7,<=2.0.0
|
||||
dashscope>=1.13.6
|
||||
volcengine>=1.0.119
|
||||
pymilvus>=2.3.4
|
||||
|
|
@ -61,17 +61,15 @@ pymilvus>=2.3.4
|
|||
|
||||
arxiv>=2.0.0
|
||||
youtube-search>=2.1.2
|
||||
duckduckgo-search>=4.1.0
|
||||
duckduckgo-search>=3.9.9
|
||||
metaphor-python>=0.1.23
|
||||
|
||||
# WebUI requirements
|
||||
|
||||
streamlit>=1.29.0
|
||||
streamlit~=1.29.0
|
||||
streamlit-option-menu>=0.3.6
|
||||
streamlit-antd-components>=0.2.4
|
||||
streamlit-chatbox>=1.1.11
|
||||
streamlit-chatbox==1.1.11
|
||||
streamlit-modal>=0.1.0
|
||||
streamlit-aggrid>=0.3.4.post3
|
||||
httpx[brotli,http2,socks]>=0.25.2
|
||||
watchdog>=3.0.0
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
# API requirements
|
||||
|
||||
torch>=2.1.2
|
||||
torchvision>=0.16.2
|
||||
torchaudio>=2.1.2
|
||||
# On Windows system, install the cuda version manually from https://pytorch.org/
|
||||
torch~=2.1.2
|
||||
torchvision~=0.16.2
|
||||
torchaudio~=2.1.2
|
||||
|
||||
langchain>=0.0.352
|
||||
langchain-experimental>=0.0.47
|
||||
langchain==0.0.352
|
||||
langchain-experimental==0.0.47
|
||||
pydantic==1.10.13
|
||||
fschat>=0.2.34
|
||||
xformers>=0.0.23.post1
|
||||
openai>=1.6.0
|
||||
sentence_transformers>=2.2.2
|
||||
transformers>=4.36.2
|
||||
fschat==0.2.34
|
||||
xformers==0.0.23.post1
|
||||
openai~=1.6.0
|
||||
sentence_transformers==2.2.2
|
||||
transformers==4.36.2
|
||||
fastapi>=0.105
|
||||
nltk>=3.8.1
|
||||
uvicorn>=0.24.0.post1
|
||||
|
|
@ -19,11 +20,11 @@ starlette~=0.27.0
|
|||
unstructured[all-docs]==0.11.0
|
||||
python-magic-bin; sys_platform == 'win32'
|
||||
SQLAlchemy==2.0.19
|
||||
faiss-cpu>=1.7.4
|
||||
accelerate>=0.24.1
|
||||
spacy>=3.7.2
|
||||
PyMuPDF>=1.23.8
|
||||
rapidocr_onnxruntime>=1.3.8
|
||||
faiss-cpu~=1.7.4
|
||||
accelerate==0.24.1
|
||||
spacy~=3.7.2
|
||||
PyMuPDF~=1.23.8
|
||||
rapidocr_onnxruntime~=1.3.8
|
||||
requests>=2.31.0
|
||||
pathlib>=1.0.1
|
||||
pytest>=7.4.3
|
||||
|
|
@ -36,16 +37,16 @@ websockets>=12.0
|
|||
numpy~=1.26.2
|
||||
pandas~=2.1.4
|
||||
einops>=0.7.0
|
||||
transformers_stream_generator>=0.0.4
|
||||
vllm>=0.2.6; sys_platform == "linux"
|
||||
transformers_stream_generator==0.0.4
|
||||
vllm==0.2.6; sys_platform == "linux"
|
||||
|
||||
# optional document loaders
|
||||
|
||||
rapidocr_paddle[gpu]>=1.3.0.post5
|
||||
jq>=1.6.0
|
||||
html2text
|
||||
beautifulsoup4>=4.12.2
|
||||
pysrt>=1.1.2
|
||||
beautifulsoup4~=4.12.2
|
||||
pysrt~=1.1.2
|
||||
|
||||
# Online api libs dependencies
|
||||
|
||||
|
|
@ -60,5 +61,5 @@ pymilvus>=2.3.4
|
|||
|
||||
arxiv>=2.0.0
|
||||
youtube-search>=2.1.2
|
||||
duckduckgo-search>=4.1.0
|
||||
duckduckgo-search>=3.9.9
|
||||
metaphor-python>=0.1.23
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
# WebUI requirements
|
||||
|
||||
streamlit>=1.29.0 # do remember to add streamlit to environment variables if you use windows
|
||||
streamlit~=1.29.0
|
||||
streamlit-option-menu>=0.3.6
|
||||
streamlit-chatbox>=1.1.11
|
||||
streamlit-chatbox==1.1.11
|
||||
streamlit-modal>=0.1.0
|
||||
streamlit-aggrid>=0.3.4.post3
|
||||
httpx[brotli,http2,socks]>=0.25.2
|
||||
watchdog>=3.0.0
|
||||
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ async def file_chat(query: str = Body(..., description="用户输入", examples=
|
|||
|
||||
context = "\n".join([doc.page_content for doc in docs])
|
||||
if len(docs) == 0: ## 如果没有找到相关文档,使用Empty模板
|
||||
prompt_template = get_prompt_template("knowledge_base_chat", "Empty")
|
||||
prompt_template = get_prompt_template("knowledge_base_chat", "empty")
|
||||
else:
|
||||
prompt_template = get_prompt_template("knowledge_base_chat", prompt_name)
|
||||
input_msg = History(role="user", content=prompt_template).to_msg_template(False)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ from fastapi import Body
|
|||
from fastapi.concurrency import run_in_threadpool
|
||||
from typing import Dict, List
|
||||
|
||||
|
||||
online_embed_models = list_online_embed_models()
|
||||
|
||||
|
||||
|
|
@ -29,9 +28,10 @@ def embed_texts(
|
|||
if embed_model in list_online_embed_models(): # 使用在线API
|
||||
config = get_model_worker_config(embed_model)
|
||||
worker_class = config.get("worker_class")
|
||||
embed_model = config.get("embed_model")
|
||||
worker = worker_class()
|
||||
if worker_class.can_embedding():
|
||||
params = ApiEmbeddingsParams(texts=texts, to_query=to_query)
|
||||
params = ApiEmbeddingsParams(texts=texts, to_query=to_query, embed_model=embed_model)
|
||||
resp = worker.do_embeddings(params)
|
||||
return BaseResponse(**resp)
|
||||
|
||||
|
|
@ -68,7 +68,8 @@ async def aembed_texts(
|
|||
|
||||
def embed_texts_endpoint(
|
||||
texts: List[str] = Body(..., description="要嵌入的文本列表", examples=[["hello", "world"]]),
|
||||
embed_model: str = Body(EMBEDDING_MODEL, description=f"使用的嵌入模型,除了本地部署的Embedding模型,也支持在线API({online_embed_models})提供的嵌入服务。"),
|
||||
embed_model: str = Body(EMBEDDING_MODEL,
|
||||
description=f"使用的嵌入模型,除了本地部署的Embedding模型,也支持在线API({online_embed_models})提供的嵌入服务。"),
|
||||
to_query: bool = Body(False, description="向量是否用于查询。有些模型如Minimax对存储/查询的向量进行了区分优化。"),
|
||||
) -> BaseResponse:
|
||||
'''
|
||||
|
|
|
|||
|
|
@ -113,6 +113,9 @@ class ApiModelWorker(BaseModelWorker):
|
|||
sys.stdout = sys.__stdout__
|
||||
sys.stderr = sys.__stderr__
|
||||
|
||||
new_loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(new_loop)
|
||||
|
||||
self.context_len = context_len
|
||||
self.semaphore = asyncio.Semaphore(self.limit_worker_concurrency)
|
||||
self.version = None
|
||||
|
|
|
|||
Loading…
Reference in New Issue