kanli commited on
Commit
c752b4a
·
1 Parent(s): c9ca0fa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -46,6 +46,13 @@ def answer(question, history=[]):
46
  print(responses)
47
  txt.update("")
48
  return responses, history
 
 
 
 
 
 
 
49
  with gr.Blocks(css="#chatbot{height:300px} .overflow-y-auto{height:500px}") as rxbot:
50
  chatbot = gr.Chatbot(elem_id="chatbot")
51
  state = gr.State([])
@@ -54,6 +61,7 @@ with gr.Blocks(css="#chatbot{height:300px} .overflow-y-auto{height:500px}") as r
54
  submit_btn = gr.Button("提交")
55
  txt.submit(answer, [txt, state], [chatbot, state])
56
  submit_btn.click(answer, [txt, state], [chatbot, state])
 
57
  # clear = gr.ClearButton([txt, chatbot])
58
 
59
  rxbot.launch(share=True)
 
46
  print(responses)
47
  txt.update("")
48
  return responses, history
49
+ def reset_user_input():
50
+ return gr.update(value='')
51
+
52
+
53
+ def reset_state():
54
+ return [], []
55
+
56
  with gr.Blocks(css="#chatbot{height:300px} .overflow-y-auto{height:500px}") as rxbot:
57
  chatbot = gr.Chatbot(elem_id="chatbot")
58
  state = gr.State([])
 
61
  submit_btn = gr.Button("提交")
62
  txt.submit(answer, [txt, state], [chatbot, state])
63
  submit_btn.click(answer, [txt, state], [chatbot, state])
64
+ submit_btn.click(reset_user_input, [], [user_input])
65
  # clear = gr.ClearButton([txt, chatbot])
66
 
67
  rxbot.launch(share=True)