Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
zqt 2023-08-26 12:22:59 +08:00
commit 7cbd8ee089
9 changed files with 58 additions and 44 deletions

View File

@ -42,7 +42,7 @@
🚩 本项目未涉及微调、训练过程,但可利用微调或训练对本项目效果进行优化。 🚩 本项目未涉及微调、训练过程,但可利用微调或训练对本项目效果进行优化。
🌐 [AutoDL 镜像](https://www.codewithgpu.com/i/imClumsyPanda/langchain-ChatGLM/Langchain-Chatchat) 中 `v5` 版本所使用代码已更新至本项目 `0.2.0` 版本。 🌐 [AutoDL 镜像](https://www.codewithgpu.com/i/imClumsyPanda/langchain-ChatGLM/Langchain-Chatchat) 中 `v6` 版本所使用代码已更新至本项目 `0.2.2` 版本。
🐳 [Docker 镜像](registry.cn-beijing.aliyuncs.com/chatchat/chatchat:0.2.0) 🐳 [Docker 镜像](registry.cn-beijing.aliyuncs.com/chatchat/chatchat:0.2.0)
@ -208,7 +208,8 @@ embedding_model_dict = {
"m3e-base": "/Users/xxx/Downloads/m3e-base", "m3e-base": "/Users/xxx/Downloads/m3e-base",
} }
``` ```
如果你选择使用OpenAI的Embedding模型请将模型的```key```写入`embedding_model_dict`中。使用该模型你需要鞥能够访问OpenAI官的API或设置代理。
如果你选择使用OpenAI的Embedding模型请将模型的 ``key``写入 `embedding_model_dict`中。使用该模型你需要鞥能够访问OpenAI官的API或设置代理。
### 4. 知识库初始化与迁移 ### 4. 知识库初始化与迁移
@ -308,7 +309,6 @@ $ python server/llm_api_shutdown.py --serve all
![image](https://github.com/chatchat-space/Langchain-Chatchat/assets/22924096/4e056c1c-5c4b-4865-a1af-859cd58a625d) ![image](https://github.com/chatchat-space/Langchain-Chatchat/assets/22924096/4e056c1c-5c4b-4865-a1af-859cd58a625d)
#### 5.2 启动 API 服务 #### 5.2 启动 API 服务
本地部署情况下,按照 [5.1 节](README.md#5.1-启动-LLM-服务)**启动 LLM 服务后**,再执行 [server/api.py](server/api.py) 脚本启动 **API** 服务; 本地部署情况下,按照 [5.1 节](README.md#5.1-启动-LLM-服务)**启动 LLM 服务后**,再执行 [server/api.py](server/api.py) 脚本启动 **API** 服务;
@ -370,13 +370,9 @@ $ python startup.py -a
`-m (或--model-worker)`, `--api`, `--webui`,其中: `-m (或--model-worker)`, `--api`, `--webui`,其中:
- `--all-webui` 为一键启动 WebUI 所有依赖服务; - `--all-webui` 为一键启动 WebUI 所有依赖服务;
- `--all-api` 为一键启动 API 所有依赖服务; - `--all-api` 为一键启动 API 所有依赖服务;
- `--llm-api` 为一键启动 Fastchat 所有依赖的 LLM 服务; - `--llm-api` 为一键启动 Fastchat 所有依赖的 LLM 服务;
- `--openai-api` 为仅启动 FastChat 的 controller 和 openai-api-server 服务; - `--openai-api` 为仅启动 FastChat 的 controller 和 openai-api-server 服务;
- 其他为单独服务启动选项。 - 其他为单独服务启动选项。
若想指定非默认模型,需要用 `--model-name` 选项,示例: 若想指定非默认模型,需要用 `--model-name` 选项,示例:
@ -393,6 +389,8 @@ $ python startup.py --all-webui --model-name Qwen-7B-Chat
**2.服务启动时间示设备不同而不同,约 3-10 分钟,如长时间没有启动请前往 `./logs`目录下监控日志,定位问题。** **2.服务启动时间示设备不同而不同,约 3-10 分钟,如长时间没有启动请前往 `./logs`目录下监控日志,定位问题。**
**3. 在Linux上使用ctrl+C退出可能会由于linux的多进程机制导致multiprocessing遗留孤儿进程可通过shutdown_all.sh进行退出**
## 常见问题 ## 常见问题
参见 [常见问题](docs/FAQ.md)。 参见 [常见问题](docs/FAQ.md)。

View File

@ -1,4 +1,4 @@
from .model_config import * from .model_config import *
from .server_config import * from .server_config import *
VERSION = "v0.2.2-preview" VERSION = "v0.2.3-preview"

View File

@ -34,11 +34,11 @@ FSCHAT_MODEL_WORKERS = {
"port": 20002, "port": 20002,
"device": LLM_DEVICE, "device": LLM_DEVICE,
# todo: 多卡加载需要配置的参数 # todo: 多卡加载需要配置的参数
"gpus": None, "gpus": None, # 使用的GPU以str的格式指定如"0,1"
"numgpus": 1, "num_gpus": 1, # 使用GPU的数量
# 以下为非常用参数,可根据需要配置 # 以下为非常用参数,可根据需要配置
# "max_gpu_memory": "20GiB", # "max_gpu_memory": "20GiB", # 每个GPU占用的最大显存
# "load_8bit": False, # "load_8bit": False, # 开启8bit量化
# "cpu_offloading": None, # "cpu_offloading": None,
# "gptq_ckpt": None, # "gptq_ckpt": None,
# "gptq_wbits": 16, # "gptq_wbits": 16,

View File

@ -14,6 +14,8 @@ python-magic-bin; sys_platform == 'win32'
SQLAlchemy==2.0.19 SQLAlchemy==2.0.19
faiss-cpu faiss-cpu
nltk nltk
accelerate
spacy
# uncomment libs if you want to use corresponding vector store # uncomment libs if you want to use corresponding vector store
# pymilvus==2.1.3 # requires milvus==2.1.3 # pymilvus==2.1.3 # requires milvus==2.1.3
@ -22,9 +24,10 @@ nltk
numpy~=1.24.4 numpy~=1.24.4
pandas~=2.0.3 pandas~=2.0.3
streamlit>=1.25.0 streamlit>=1.26.0
streamlit-option-menu>=0.3.6 streamlit-option-menu>=0.3.6
streamlit-antd-components>=0.1.11 streamlit-antd-components>=0.1.11
streamlit-chatbox>=1.1.6 streamlit-chatbox>=1.1.6
streamlit-aggrid>=0.3.4.post3 streamlit-aggrid>=0.3.4.post3
httpx~=0.24.1 httpx~=0.24.1
watchdog

View File

@ -14,6 +14,8 @@ python-magic-bin; sys_platform == 'win32'
SQLAlchemy==2.0.19 SQLAlchemy==2.0.19
faiss-cpu faiss-cpu
nltk nltk
accelerate
spacy
# uncomment libs if you want to use corresponding vector store # uncomment libs if you want to use corresponding vector store
# pymilvus==2.1.3 # requires milvus==2.1.3 # pymilvus==2.1.3 # requires milvus==2.1.3

View File

@ -1,9 +1,10 @@
numpy~=1.24.4 numpy~=1.24.4
pandas~=2.0.3 pandas~=2.0.3
streamlit>=1.25.0 streamlit>=1.26.0
streamlit-option-menu>=0.3.6 streamlit-option-menu>=0.3.6
streamlit-antd-components>=0.1.11 streamlit-antd-components>=0.1.11
streamlit-chatbox>=1.1.6 streamlit-chatbox>=1.1.6
streamlit-aggrid>=0.3.4.post3 streamlit-aggrid>=0.3.4.post3
httpx~=0.24.1 httpx~=0.24.1
nltk nltk
watchdog

View File

@ -104,6 +104,9 @@ class KnowledgeFile:
else: else:
loader = DocumentLoader(self.filepath) loader = DocumentLoader(self.filepath)
if self.ext in ".csv":
docs = loader.load()
else:
try: try:
if self.text_splitter_name is None: if self.text_splitter_name is None:
text_splitter_module = importlib.import_module('langchain.text_splitter') text_splitter_module = importlib.import_module('langchain.text_splitter')

View File

@ -1 +1,2 @@
ps -eo pid,user,cmd|grep -P 'server/api.py|webui.py|fastchat.serve'|grep -v grep|awk '{print $1}'|xargs kill -9 # mac设备上的grep命令可能不支持grep -P选项请使用Homebrew安装;或使用ggrep命令
ps -eo pid,user,cmd|grep -P 'server/api.py|webui.py|fastchat.serve|multiprocessing'|grep -v grep|awk '{print $1}'|xargs kill -9

View File

@ -80,8 +80,13 @@ def dialogue_page(api: ApiRequest):
# chunk_content = st.checkbox("关联上下文", False, disabled=True) # chunk_content = st.checkbox("关联上下文", False, disabled=True)
# chunk_size = st.slider("关联长度:", 0, 500, 250, disabled=True) # chunk_size = st.slider("关联长度:", 0, 500, 250, disabled=True)
elif dialogue_mode == "搜索引擎问答": elif dialogue_mode == "搜索引擎问答":
search_engine_list = list(SEARCH_ENGINES.keys())
with st.expander("搜索引擎配置", True): with st.expander("搜索引擎配置", True):
search_engine = st.selectbox("请选择搜索引擎", SEARCH_ENGINES.keys(), 0) search_engine = st.selectbox(
label="请选择搜索引擎",
options=search_engine_list,
index=search_engine_list.index("duckduckgo") if "duckduckgo" in search_engine_list else 0,
)
se_top_k = st.number_input("匹配搜索结果条数:", 1, 20, 3) se_top_k = st.number_input("匹配搜索结果条数:", 1, 20, 3)
# Display chat messages from history on app rerun # Display chat messages from history on app rerun
@ -127,6 +132,7 @@ def dialogue_page(api: ApiRequest):
for d in api.search_engine_chat(prompt, search_engine, se_top_k): for d in api.search_engine_chat(prompt, search_engine, se_top_k):
if error_msg := check_error_msg(d): # check whether error occured if error_msg := check_error_msg(d): # check whether error occured
st.error(error_msg) st.error(error_msg)
else:
text += d["answer"] text += d["answer"]
chat_box.update_msg(text, 0) chat_box.update_msg(text, 0)
chat_box.update_msg("\n\n".join(d["docs"]), 1, streaming=False) chat_box.update_msg("\n\n".join(d["docs"]), 1, streaming=False)