wholewhale commited on
Commit
a08bac4
1 Parent(s): b505ef9

clear data button

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -28,6 +28,11 @@ def pdf_changes(pdf_doc):
28
  return_source_documents=False)
29
  return "Ready"
30
 
 
 
 
 
 
31
  def add_text(history, text):
32
  history = history + [(text, None)]
33
  return history, ""
@@ -75,13 +80,15 @@ with gr.Blocks(css=css) as demo:
75
  with gr.Row():
76
  langchain_status = gr.Textbox(label="Status", placeholder="", interactive=False)
77
  load_pdf = gr.Button("Convert PDF to Magic AI language")
 
78
 
79
- chatbot = gr.Chatbot([], elem_id="chatbot", show_copy_button=True).style(height=350)
80
  question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter")
81
  submit_btn = gr.Button("Send Message")
82
-
83
  load_pdf.click(loading_pdf, None, langchain_status, queue=False)
84
  load_pdf.click(pdf_changes, inputs=[pdf_doc], outputs=[langchain_status], queue=False)
 
85
  question.submit(add_text, [chatbot, question], [chatbot, question]).then(
86
  bot, chatbot, chatbot
87
  )
 
28
  return_source_documents=False)
29
  return "Ready"
30
 
31
+ def clear_data():
32
+ global qa
33
+ qa = None
34
+ return "Data cleared"
35
+
36
  def add_text(history, text):
37
  history = history + [(text, None)]
38
  return history, ""
 
80
  with gr.Row():
81
  langchain_status = gr.Textbox(label="Status", placeholder="", interactive=False)
82
  load_pdf = gr.Button("Convert PDF to Magic AI language")
83
+ clear_btn = gr.Button("Clear Data")
84
 
85
+ chatbot = gr.Chatbot([], elem_id="chatbot").style(height=350)
86
  question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter")
87
  submit_btn = gr.Button("Send Message")
88
+
89
  load_pdf.click(loading_pdf, None, langchain_status, queue=False)
90
  load_pdf.click(pdf_changes, inputs=[pdf_doc], outputs=[langchain_status], queue=False)
91
+ clear_btn.click(clear_data, outputs=[langchain_status], queue=False)
92
  question.submit(add_text, [chatbot, question], [chatbot, question]).then(
93
  bot, chatbot, chatbot
94
  )