知识库插件修正
This commit is contained in:
parent
49f3fcf2c0
commit
8a6e96c369
12
Dockerfile
12
Dockerfile
@ -23,13 +23,11 @@ RUN pip3 install -r requirements.txt
|
|||||||
|
|
||||||
|
|
||||||
# 装载项目文件,安装剩余依赖(必要)
|
# 装载项目文件,安装剩余依赖(必要)
|
||||||
|
RUN pip3 install torch --index-url https://download.pytorch.org/whl/cpu
|
||||||
|
RUN pip3 install langchain sentence-transformers unstructured[local-inference] faiss-cpu nltk beautifulsoup4 bitsandbytes tabulate icetk
|
||||||
|
|
||||||
|
COPY .cache /root/.cache
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN pip3 install -r requirements.txt
|
RUN pip3 install -r requirements.txt
|
||||||
|
|
||||||
|
|
||||||
# 非必要步骤,用于预热模块(可以删除)
|
|
||||||
RUN python3 -c 'from check_proxy import warm_up_modules; warm_up_modules()'
|
|
||||||
|
|
||||||
|
|
||||||
# 启动(必要)
|
# 启动(必要)
|
||||||
CMD ["python3", "-u", "main.py"]
|
CMD ["python3", "-u", "tests/test_vector_plugins.py"]
|
||||||
|
@ -301,7 +301,6 @@ class knowledge_archive_interface():
|
|||||||
self.threadLock.acquire()
|
self.threadLock.acquire()
|
||||||
# import uuid
|
# import uuid
|
||||||
self.current_id = id
|
self.current_id = id
|
||||||
from zh_langchain import construct_vector_store
|
|
||||||
self.qa_handle, self.kai_path = construct_vector_store(
|
self.qa_handle, self.kai_path = construct_vector_store(
|
||||||
vs_id=self.current_id,
|
vs_id=self.current_id,
|
||||||
files=file_manifest,
|
files=file_manifest,
|
||||||
@ -323,7 +322,6 @@ class knowledge_archive_interface():
|
|||||||
self.threadLock.acquire()
|
self.threadLock.acquire()
|
||||||
if not self.current_id == id:
|
if not self.current_id == id:
|
||||||
self.current_id = id
|
self.current_id = id
|
||||||
from zh_langchain import construct_vector_store
|
|
||||||
self.qa_handle, self.kai_path = construct_vector_store(
|
self.qa_handle, self.kai_path = construct_vector_store(
|
||||||
vs_id=self.current_id,
|
vs_id=self.current_id,
|
||||||
files=[],
|
files=[],
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
from toolbox import CatchException, update_ui, ProxyNetworkActivate, update_ui_lastest_msg
|
from toolbox import CatchException, update_ui, ProxyNetworkActivate, update_ui_lastest_msg
|
||||||
from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive, get_files_from_everything
|
from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive, get_files_from_everything
|
||||||
|
|
||||||
|
install_msg ="""
|
||||||
|
pip3 install torch --index-url https://download.pytorch.org/whl/cpu
|
||||||
|
pip3 install langchain sentence-transformers unstructured[local-inference] faiss-cpu nltk beautifulsoup4 bitsandbytes tabulate icetk
|
||||||
|
"""
|
||||||
|
|
||||||
@CatchException
|
@CatchException
|
||||||
def 知识库文件注入(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
def 知识库文件注入(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
||||||
@ -29,11 +32,11 @@ def 知识库文件注入(txt, llm_kwargs, plugin_kwargs, chatbot, history, syst
|
|||||||
# from langchain.embeddings.huggingface import HuggingFaceEmbeddings
|
# from langchain.embeddings.huggingface import HuggingFaceEmbeddings
|
||||||
from crazy_functions.vector_fns.vector_database import knowledge_archive_interface
|
from crazy_functions.vector_fns.vector_database import knowledge_archive_interface
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
chatbot.append(["依赖不足", "导入依赖失败。正在尝试自动安装,请查看终端的输出或耐心等待..."])
|
chatbot.append(["依赖不足", f"{str(e)}\n\n导入依赖失败。请用以下命令安装" + install_msg])
|
||||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||||
from .crazy_utils import try_install_deps
|
# from .crazy_utils import try_install_deps
|
||||||
try_install_deps(['zh_langchain==0.2.1', 'pypinyin'], reload_m=['pypinyin', 'zh_langchain'])
|
# try_install_deps(['zh_langchain==0.2.1', 'pypinyin'], reload_m=['pypinyin', 'zh_langchain'])
|
||||||
yield from update_ui_lastest_msg("安装完成,您可以再次重试。", chatbot, history)
|
# yield from update_ui_lastest_msg("安装完成,您可以再次重试。", chatbot, history)
|
||||||
return
|
return
|
||||||
|
|
||||||
# < --------------------读取文件--------------- >
|
# < --------------------读取文件--------------- >
|
||||||
@ -81,11 +84,11 @@ def 读取知识库作答(txt, llm_kwargs, plugin_kwargs, chatbot, history, syst
|
|||||||
# from langchain.embeddings.huggingface import HuggingFaceEmbeddings
|
# from langchain.embeddings.huggingface import HuggingFaceEmbeddings
|
||||||
from crazy_functions.vector_fns.vector_database import knowledge_archive_interface
|
from crazy_functions.vector_fns.vector_database import knowledge_archive_interface
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
chatbot.append(["依赖不足", "导入依赖失败。正在尝试自动安装,请查看终端的输出或耐心等待..."])
|
chatbot.append(["依赖不足", f"{str(e)}\n\n导入依赖失败。请用以下命令安装" + install_msg])
|
||||||
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
||||||
from .crazy_utils import try_install_deps
|
# from .crazy_utils import try_install_deps
|
||||||
try_install_deps(['zh_langchain==0.2.1', 'pypinyin'], reload_m=['pypinyin', 'zh_langchain'])
|
# try_install_deps(['zh_langchain==0.2.1', 'pypinyin'], reload_m=['pypinyin', 'zh_langchain'])
|
||||||
yield from update_ui_lastest_msg("安装完成,您可以再次重试。", chatbot, history)
|
# yield from update_ui_lastest_msg("安装完成,您可以再次重试。", chatbot, history)
|
||||||
return
|
return
|
||||||
|
|
||||||
# < ------------------- --------------- >
|
# < ------------------- --------------- >
|
||||||
|
Loading…
x
Reference in New Issue
Block a user