HelenaXH commited on
Commit
7692476
·
verified ·
1 Parent(s): 76a4e39

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -833,16 +833,15 @@ with gr.Blocks(css=css) as demo:
833
 
834
  chatbot = gr.Chatbot(height=500, show_label=False, show_copy_button=True, type="messages")
835
  msg = gr.Textbox(placeholder="请输入你的回答...")
836
- send = gr.Button("发送 🚀", elem_id="custom-send")
837
- reset = gr.Button("🔄 重新开始")
838
 
839
- # 用户输入后将其加入历史
840
  def add_user_message(m, hist):
841
  hist = hist or []
842
  hist.append({"role": "user", "content": m})
843
  return "", hist
844
 
845
- # 自动调用主逻辑函数
846
  def add_bot_response(hist):
847
  user_msg = hist[-1]["content"]
848
  bot_msg = predict(user_msg, hist[:-1])
@@ -855,7 +854,6 @@ with gr.Blocks(css=css) as demo:
855
  msg.submit(add_user_message, [msg, chatbot], [msg, chatbot]) \
856
  .then(add_bot_response, chatbot, chatbot)
857
 
858
- # 重置状态逻辑
859
  def reset_state():
860
  global current_q_index, questions
861
  global in_forward_flow, in_backward_flow
@@ -895,7 +893,7 @@ with gr.Blocks(css=css) as demo:
895
 
896
  reset.click(reset_state, outputs=chatbot)
897
 
898
- # 首次加载时自动触发欢迎提问
899
  def auto_first():
900
  return [{"role": "assistant", "content": questions[0][1]}]
901
 
 
833
 
834
  chatbot = gr.Chatbot(height=500, show_label=False, show_copy_button=True, type="messages")
835
  msg = gr.Textbox(placeholder="请输入你的回答...")
836
+ send = gr.Button("Send 🚀", elem_id="custom-send")
837
+ reset = gr.Button("🔄 Restart")
838
 
 
839
  def add_user_message(m, hist):
840
  hist = hist or []
841
  hist.append({"role": "user", "content": m})
842
  return "", hist
843
 
844
+
845
  def add_bot_response(hist):
846
  user_msg = hist[-1]["content"]
847
  bot_msg = predict(user_msg, hist[:-1])
 
854
  msg.submit(add_user_message, [msg, chatbot], [msg, chatbot]) \
855
  .then(add_bot_response, chatbot, chatbot)
856
 
 
857
  def reset_state():
858
  global current_q_index, questions
859
  global in_forward_flow, in_backward_flow
 
893
 
894
  reset.click(reset_state, outputs=chatbot)
895
 
896
+
897
  def auto_first():
898
  return [{"role": "assistant", "content": questions[0][1]}]
899