feature@add searcht vs search+llm

This commit is contained in:
yanqiang 2023-04-17 17:31:54 +08:00
parent 46670ec7de
commit 6af4300637
3 changed files with 20 additions and 14 deletions

View File

@ -15,8 +15,8 @@
## 🔨 TODO
* [x] 支持上下文
* [x] 支持知识增量更新
* [ ] 支持检索结果与LLM生成结果对比
* [x] 支持检索结果与LLM生成结果对比
* [ ] 支持检索生成结果与原始LLM生成结果对比
## ❤️引用
- webui参考https://github.com/thomas-yanxin/LangChain-ChatGLM-Webui

View File

@ -1,2 +1,2 @@
马保国1952年- [1] ,英国混元太极拳协会创始人,自称“浑元形意太极拳掌门人”。 [2-4]
2020年11月15日马保国首度回应“屡遭恶搞剪辑”“远离武林已回归平静生活” [5] 11月16日马保国宣布将参演电影《少年功夫王》。 [6] 11月28日人民日报客户端刊发评论《马保国闹剧该立刻收场了》。 [7] 11月29日新浪微博社区管理官方发布公告称已解散马保国相关的粉丝群。 [8]
马保国1952年- ,英国混元太极拳协会创始人,自称“浑元形意太极拳掌门人”。
2020年11月15日马保国首度回应“屡遭恶搞剪辑”“远离武林已回归平静生活” 11月16日马保国宣布将参演电影《少年功夫王》。 11月28日人民日报客户端刊发评论《马保国闹剧该立刻收场了》。 11月29日新浪微博社区管理官方发布公告称已解散马保国相关的粉丝群。

26
main.py
View File

@ -70,7 +70,11 @@ def predict(input,
)
print(resp)
history.append((input, resp['result']))
return '', history, history
search_text = ''
for idx, source in enumerate(resp['source_documents'][:2]):
search_text += f'【搜索结果{idx}:】{source.page_content}\n\n'
return '', history, history, search_text
block = gr.Blocks()
@ -108,20 +112,23 @@ with block as demo:
inputs=file,
outputs=selectFile)
with gr.Column(scale=4):
chatbot = gr.Chatbot(label='Chinese-LangChain').style(height=400)
message = gr.Textbox(label='请输入问题')
state = gr.State()
with gr.Row():
clear_history = gr.Button("🧹 清除历史对话")
send = gr.Button("🚀 发送")
with gr.Column(scale=4):
chatbot = gr.Chatbot(label='Chinese-LangChain').style(height=400)
message = gr.Textbox(label='请输入问题')
with gr.Row():
clear_history = gr.Button("🧹 清除历史对话")
send = gr.Button("🚀 发送")
with gr.Column(scale=2):
search = gr.Textbox(label='搜索结果')
# 发送按钮 提交
send.click(predict,
inputs=[
message, large_language_model,
embedding_model, state
],
outputs=[message, chatbot, state])
outputs=[message, chatbot, state, search])
# 清空历史对话按钮 提交
clear_history.click(fn=clear_session,
@ -135,7 +142,6 @@ with block as demo:
message, large_language_model,
embedding_model, state
],
outputs=[message, chatbot, state])
with gr.Column(scale=2):
message = gr.Textbox(label='搜索结果')
outputs=[message, chatbot, state, search])
demo.queue().launch(server_name='0.0.0.0', server_port=8008, share=False)