Unverified 提交 b22e15ab 作者: 郑肖峰 提交者: GitHub

Vs refresh (#529)

* Update README.md

* Add files via upload

* Update README.md

* Update README.md

* gradio webui 刷新页面更新知识库列表

* update webui.py

---------

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
Co-authored-by: 扶桑 <fusang@myweimai.com>
上级 5290730d
......@@ -12,6 +12,8 @@
⛓️ 本项目实现原理如下图所示,过程包括加载文件 -> 读取文本 -> 文本分割 -> 文本向量化 -> 问句向量化 -> 在文本向量中匹配出与问句向量最相似的`top k`个 -> 匹配出的文本作为上下文和问题一起添加到`prompt`中 -> 提交给`LLM`生成回答。
📺 [原理介绍视频](https://www.bilibili.com/video/BV13M4y1e7cN/?share_source=copy_web&vd_source=e6c5aafe684f30fbe41925d61ca6d514)
![实现原理图](img/langchain+chatglm.png)
从文档处理角度来看,实现流程如下:
......@@ -225,6 +227,6 @@ Web UI 可以实现如下功能:
- [x] VUE 前端
## 项目交流群
![二维码](img/qr_code_25.JPG)
![二维码](img/qr_code_26.jpg)
🎉 langchain-ChatGLM 项目交流群,如果你也对本项目感兴趣,欢迎加入群聊参与讨论交流。
......@@ -249,7 +249,7 @@ def reinit_vector_store(vs_id, history):
def refresh_vs_list():
return gr.update(choices=get_vs_list())
return gr.update(choices=get_vs_list()), gr.update(choices=get_vs_list())
block_css = """.importantButton {
......@@ -393,7 +393,7 @@ with gr.Blocks(css=block_css, theme=gr.themes.Default(**default_theme_args)) as
outputs=[chunk_sizes, chatbot])
with vs_setting:
vs_refresh = gr.Button("更新已有知识库选项")
select_vs = gr.Dropdown(get_vs_list(),
select_vs_test = gr.Dropdown(get_vs_list(),
label="请选择要加载的知识库",
interactive=True,
value=get_vs_list()[0] if len(get_vs_list()) > 0 else None)
......@@ -431,25 +431,25 @@ with gr.Blocks(css=block_css, theme=gr.themes.Default(**default_theme_args)) as
# 将上传的文件保存到content文件夹下,并更新下拉框
vs_refresh.click(fn=refresh_vs_list,
inputs=[],
outputs=select_vs)
outputs=select_vs_test)
vs_add.click(fn=add_vs_name,
inputs=[vs_name, chatbot],
outputs=[select_vs, vs_name, vs_add, file2vs, chatbot])
select_vs.change(fn=change_vs_name_input,
inputs=[select_vs, chatbot],
outputs=[select_vs_test, vs_name, vs_add, file2vs, chatbot])
select_vs_test.change(fn=change_vs_name_input,
inputs=[select_vs_test, chatbot],
outputs=[vs_name, vs_add, file2vs, vs_path, chatbot])
load_file_button.click(get_vector_store,
show_progress=True,
inputs=[select_vs, files, sentence_size, chatbot, vs_add, vs_add],
inputs=[select_vs_test, files, sentence_size, chatbot, vs_add, vs_add],
outputs=[vs_path, files, chatbot], )
load_folder_button.click(get_vector_store,
show_progress=True,
inputs=[select_vs, folder_files, sentence_size, chatbot, vs_add,
inputs=[select_vs_test, folder_files, sentence_size, chatbot, vs_add,
vs_add],
outputs=[vs_path, folder_files, chatbot], )
load_conent_button.click(get_vector_store,
show_progress=True,
inputs=[select_vs, one_title, sentence_size, chatbot,
inputs=[select_vs_test, one_title, sentence_size, chatbot,
one_conent, one_content_segmentation],
outputs=[vs_path, files, chatbot], )
flag_csv_logger.setup([query, vs_path, chatbot, mode], "flagged")
......@@ -490,6 +490,14 @@ with gr.Blocks(css=block_css, theme=gr.themes.Default(**default_theme_args)) as
load_knowlege_button = gr.Button("重新构建知识库")
load_knowlege_button.click(reinit_vector_store, show_progress=True,
inputs=[select_vs, chatbot], outputs=chatbot)
demo.load(
fn=refresh_vs_list,
inputs=None,
outputs=[select_vs, select_vs_test],
queue=True,
show_progress=False,
)
(demo
.queue(concurrency_count=3)
.launch(server_name='0.0.0.0',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论