YangWu001 commited on
Commit
779c082
Β·
1 Parent(s): d5b26cf
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -56,6 +56,7 @@ def respond(
56
  def cancel_inference():
57
  global stop_inference
58
  stop_inference = True
 
59
 
60
  # Custom CSS for a fancy look
61
  custom_css = """
@@ -118,12 +119,15 @@ demo = gr.ChatInterface(
118
  label="Top-p (nucleus sampling)",
119
  ),
120
  gr.Checkbox(label="Use Local Model", value=False),
121
- gr.Button("Cancel Inference", variant="danger", on_click=cancel_inference),
122
  ],
123
  css=custom_css,
124
  title="🌟 Fancy AI Chatbot 🌟",
125
  description="Interact with the AI chatbot using customizable settings below."
126
  )
127
 
 
 
 
128
  if __name__ == "__main__":
129
  demo.launch()
 
56
  def cancel_inference():
57
  global stop_inference
58
  stop_inference = True
59
+ return gr.update(label="Inference cancelled.")
60
 
61
  # Custom CSS for a fancy look
62
  custom_css = """
 
119
  label="Top-p (nucleus sampling)",
120
  ),
121
  gr.Checkbox(label="Use Local Model", value=False),
122
+ gr.Button("Cancel Inference"),
123
  ],
124
  css=custom_css,
125
  title="🌟 Fancy AI Chatbot 🌟",
126
  description="Interact with the AI chatbot using customizable settings below."
127
  )
128
 
129
+ cancel_button = demo.add_button("Cancel Inference", variant="danger", elem_id="cancel_button")
130
+ cancel_button.click(cancel_inference, None, None)
131
+
132
  if __name__ == "__main__":
133
  demo.launch()