Unverified 提交 875dae64 作者: zhoutongqing 提交者: GitHub

zhoutongqing:添加重新构建知识库功能 (#418)

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
上级 f7044f6f
......@@ -229,6 +229,22 @@ def add_vs_name(vs_name, chatbot):
chatbot = chatbot + [[None, vs_status]]
return gr.update(visible=True, choices=get_vs_list(), value=vs_name), gr.update(
visible=False), gr.update(visible=False), gr.update(visible=True), chatbot
# 自动化加载固定文件间中文件
def init_set_vector_store(content_dir,vs_id,history):
try:
shutil.rmtree(VS_ROOT_PATH)
vs_path = os.path.join(VS_ROOT_PATH, vs_id)
sentence_size = gr.Number(value=SENTENCE_SIZE, precision=0,
label="文本入库分句长度限制",
interactive=True, visible=True)
vs_path, loaded_files = local_doc_qa.init_knowledge_vector_store(content_dir, vs_path, sentence_size)
model_status = """知识库构建成功"""
except Exception as e:
logger.error(e)
model_status = """知识库构建未成功"""
logger.info(model_status)
return history + [[None, model_status]]
def refresh_vs_list():
......@@ -470,7 +486,9 @@ with gr.Blocks(css=block_css, theme=gr.themes.Default(**default_theme_args)) as
load_model_button.click(reinit_model, show_progress=True,
inputs=[llm_model, embedding_model, llm_history_len, no_remote_model, use_ptuning_v2,
use_lora, top_k, chatbot], outputs=chatbot)
load_knowlege_button = gr.Button("重新构建知识库")
load_knowlege_button.click(init_set_vector_store, show_progress=True,
inputs=[UPLOAD_ROOT_PATH, select_vs,chatbot], outputs=chatbot)
(demo
.queue(concurrency_count=3)
.launch(server_name='0.0.0.0',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论