diff --git a/README.md b/README.md
index 67aa6ef..8d41b73 100644
--- a/README.md
+++ b/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)
### 项目交流群
-
+
🎉 Langchain-Chatchat 项目微信交流群,如果你也对本项目感兴趣,欢迎加入群聊参与讨论交流。
diff --git a/configs/model_config.py.example b/configs/model_config.py.example
index d07b960..be2f412 100644
--- a/configs/model_config.py.example
+++ b/configs/model_config.py.example
@@ -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",
diff --git a/img/qr_code_77.jpg b/img/qr_code_77.jpg
new file mode 100644
index 0000000..6a2ae7a
Binary files /dev/null and b/img/qr_code_77.jpg differ
diff --git a/img/qr_code_78.jpg b/img/qr_code_78.jpg
new file mode 100644
index 0000000..a85e890
Binary files /dev/null and b/img/qr_code_78.jpg differ
diff --git a/img/qr_code_79.jpg b/img/qr_code_79.jpg
new file mode 100644
index 0000000..d784160
Binary files /dev/null and b/img/qr_code_79.jpg differ
diff --git a/img/qr_code_80.jpg b/img/qr_code_80.jpg
new file mode 100644
index 0000000..ffb0e0e
Binary files /dev/null and b/img/qr_code_80.jpg differ
diff --git a/img/qr_code_81.jpg b/img/qr_code_81.jpg
new file mode 100644
index 0000000..07a4980
Binary files /dev/null and b/img/qr_code_81.jpg differ
diff --git a/img/qr_code_82.jpg b/img/qr_code_82.jpg
new file mode 100644
index 0000000..c3e0cfe
Binary files /dev/null and b/img/qr_code_82.jpg differ
diff --git a/knowledge_base/samples/content/wiki b/knowledge_base/samples/content/wiki
index 4c6f1a9..2f24adb 160000
--- a/knowledge_base/samples/content/wiki
+++ b/knowledge_base/samples/content/wiki
@@ -1 +1 @@
-Subproject commit 4c6f1a9748563b5d3ae81a628ff8a71f3e5686d1
+Subproject commit 2f24adb218f23eab00d7fcd7ccf5072f2f35cb3c
diff --git a/requirements.txt b/requirements.txt
index 830552c..5d09a6b 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -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
-
diff --git a/requirements_api.txt b/requirements_api.txt
index 4f975cf..237eb4e 100644
--- a/requirements_api.txt
+++ b/requirements_api.txt
@@ -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
\ No newline at end of file
diff --git a/requirements_webui.txt b/requirements_webui.txt
index 3113053..aa3eca7 100644
--- a/requirements_webui.txt
+++ b/requirements_webui.txt
@@ -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
-
diff --git a/server/chat/file_chat.py b/server/chat/file_chat.py
index d9ba5b6..a3bbdfc 100644
--- a/server/chat/file_chat.py
+++ b/server/chat/file_chat.py
@@ -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)
diff --git a/server/embeddings_api.py b/server/embeddings_api.py
index 93555a3..440bb77 100644
--- a/server/embeddings_api.py
+++ b/server/embeddings_api.py
@@ -6,32 +6,32 @@ from fastapi import Body
from fastapi.concurrency import run_in_threadpool
from typing import Dict, List
-
online_embed_models = list_online_embed_models()
def embed_texts(
- texts: List[str],
- embed_model: str = EMBEDDING_MODEL,
- to_query: bool = False,
+ texts: List[str],
+ embed_model: str = EMBEDDING_MODEL,
+ to_query: bool = False,
) -> BaseResponse:
'''
对文本进行向量化。返回数据格式:BaseResponse(data=List[List[float]])
TODO: 也许需要加入缓存机制,减少 token 消耗
'''
try:
- if embed_model in list_embed_models(): # 使用本地Embeddings模型
+ if embed_model in list_embed_models(): # 使用本地Embeddings模型
from server.utils import load_local_embeddings
embeddings = load_local_embeddings(model=embed_model)
return BaseResponse(data=embeddings.embed_documents(texts))
- if embed_model in list_online_embed_models(): # 使用在线API
+ 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)
@@ -67,9 +67,10 @@ 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})提供的嵌入服务。"),
- to_query: bool = Body(False, description="向量是否用于查询。有些模型如Minimax对存储/查询的向量进行了区分优化。"),
+ texts: List[str] = Body(..., description="要嵌入的文本列表", examples=[["hello", "world"]]),
+ embed_model: str = Body(EMBEDDING_MODEL,
+ description=f"使用的嵌入模型,除了本地部署的Embedding模型,也支持在线API({online_embed_models})提供的嵌入服务。"),
+ to_query: bool = Body(False, description="向量是否用于查询。有些模型如Minimax对存储/查询的向量进行了区分优化。"),
) -> BaseResponse:
'''
对文本进行向量化,返回 BaseResponse(data=List[List[float]])
@@ -78,9 +79,9 @@ def embed_texts_endpoint(
def embed_documents(
- docs: List[Document],
- embed_model: str = EMBEDDING_MODEL,
- to_query: bool = False,
+ docs: List[Document],
+ embed_model: str = EMBEDDING_MODEL,
+ to_query: bool = False,
) -> Dict:
"""
将 List[Document] 向量化,转化为 VectorStore.add_embeddings 可以接受的参数
diff --git a/server/model_workers/base.py b/server/model_workers/base.py
index 7b456a9..88affb4 100644
--- a/server/model_workers/base.py
+++ b/server/model_workers/base.py
@@ -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