yanqiang commited on
Commit
6af4300
1 Parent(s): 46670ec

feature@add searcht vs search+llm

Browse files
Files changed (3) hide show
  1. README.md +2 -2
  2. docs/added/马保国.txt +2 -2
  3. main.py +16 -10
README.md CHANGED
@@ -15,8 +15,8 @@
15
  ## 🔨 TODO
16
  * [x] 支持上下文
17
  * [x] 支持知识增量更新
18
- * [ ] 支持检索结果与LLM生成结果对比
19
-
20
  ## ❤️引用
21
 
22
  - webui参考:https://github.com/thomas-yanxin/LangChain-ChatGLM-Webui
 
15
  ## 🔨 TODO
16
  * [x] 支持上下文
17
  * [x] 支持知识增量更新
18
+ * [x] 支持检索结果与LLM生成结果对比
19
+ * [ ] 支持检索生成结果与原始LLM生成结果对比
20
  ## ❤️引用
21
 
22
  - webui参考:https://github.com/thomas-yanxin/LangChain-ChatGLM-Webui
docs/added/马保国.txt CHANGED
@@ -1,2 +1,2 @@
1
- 马保国(1952年- ) [1] ,英国混元太极拳协会创始人,自称“浑元形意太极拳掌门人”。 [2-4]
2
- 2020年11月15日,马保国首度回应“屡遭恶搞剪辑”:“远离武林,已回归平静生活” [5] ;11月16日,马保国宣布将参演电影《少年功夫王》。 [6] 11月28日,人民日报客户端刊发评论《马保国闹剧,该立刻收场了》。 [7] 11月29日,新浪微博社区管理官方发布公告称,已解散马保国相关的粉丝群。 [8]
 
1
+ 马保国(1952年- ) ,英国混元太极拳协会创始人,自称“浑元形意太极拳掌门人”。
2
+ 2020年11月15日,马保国首度回应“屡遭恶搞剪辑”:“远离武林,已回归平静生活” ;11月16日,马保国宣布将参演电影《少年功夫王》。 11月28日,人民日报客户端刊发评论《马保国闹剧,该立刻收场了》。 11月29日,新浪微博社区管理官方发布公告称,已解散马保国相关的粉丝群。
main.py CHANGED
@@ -70,7 +70,11 @@ def predict(input,
70
  )
71
  print(resp)
72
  history.append((input, resp['result']))
73
- return '', history, history
 
 
 
 
74
 
75
 
76
  block = gr.Blocks()
@@ -108,20 +112,23 @@ with block as demo:
108
  inputs=file,
109
  outputs=selectFile)
110
  with gr.Column(scale=4):
111
- chatbot = gr.Chatbot(label='Chinese-LangChain').style(height=400)
112
- message = gr.Textbox(label='请输入问题')
113
  state = gr.State()
114
  with gr.Row():
115
- clear_history = gr.Button("🧹 清除历史对话")
116
- send = gr.Button("🚀 发送")
117
-
 
 
 
 
 
118
  # 发送按钮 提交
119
  send.click(predict,
120
  inputs=[
121
  message, large_language_model,
122
  embedding_model, state
123
  ],
124
- outputs=[message, chatbot, state])
125
 
126
  # 清空历史对话按钮 提交
127
  clear_history.click(fn=clear_session,
@@ -135,7 +142,6 @@ with block as demo:
135
  message, large_language_model,
136
  embedding_model, state
137
  ],
138
- outputs=[message, chatbot, state])
139
- with gr.Column(scale=2):
140
- message = gr.Textbox(label='搜索结果')
141
  demo.queue().launch(server_name='0.0.0.0', server_port=8008, share=False)
 
70
  )
71
  print(resp)
72
  history.append((input, resp['result']))
73
+
74
+ search_text = ''
75
+ for idx, source in enumerate(resp['source_documents'][:2]):
76
+ search_text += f'【搜索结果{idx}:】{source.page_content}\n\n'
77
+ return '', history, history, search_text
78
 
79
 
80
  block = gr.Blocks()
 
112
  inputs=file,
113
  outputs=selectFile)
114
  with gr.Column(scale=4):
 
 
115
  state = gr.State()
116
  with gr.Row():
117
+ with gr.Column(scale=4):
118
+ chatbot = gr.Chatbot(label='Chinese-LangChain').style(height=400)
119
+ message = gr.Textbox(label='请输入问题')
120
+ with gr.Row():
121
+ clear_history = gr.Button("🧹 清除历史对话")
122
+ send = gr.Button("🚀 发送")
123
+ with gr.Column(scale=2):
124
+ search = gr.Textbox(label='搜索结果')
125
  # 发送按钮 提交
126
  send.click(predict,
127
  inputs=[
128
  message, large_language_model,
129
  embedding_model, state
130
  ],
131
+ outputs=[message, chatbot, state, search])
132
 
133
  # 清空历史对话按钮 提交
134
  clear_history.click(fn=clear_session,
 
142
  message, large_language_model,
143
  embedding_model, state
144
  ],
145
+ outputs=[message, chatbot, state, search])
146
+
 
147
  demo.queue().launch(server_name='0.0.0.0', server_port=8008, share=False)