ShermanAI commited on
Commit
a729ed1
·
1 Parent(s): b05100b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -36,14 +36,17 @@ inputs = [gr.inputs.Textbox(label="Enter your question: "), "state"]
36
  outputs = ["chatbot", "state"]
37
  interface = gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title=title, description=description, examples=examples)
38
 
39
- # Add JavaScript code to reset the input textbox value on the client side
40
- interface.html("""
41
- <script>
42
- function resetInput() {
43
- document.getElementById("input-textbox").value = "";
44
- }
45
- document.querySelector('[type="submit"]').addEventListener("click", resetInput);
46
- </script>
47
- """)
 
 
 
48
 
49
  interface.launch(debug=True)
 
36
  outputs = ["chatbot", "state"]
37
  interface = gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title=title, description=description, examples=examples)
38
 
39
+ # Modify the infer method to add JavaScript code to reset the input textbox value on the client side
40
+ def reset_input():
41
+ return """
42
+ <script>
43
+ function resetInput() {
44
+ document.getElementById("input-textbox").value = "";
45
+ }
46
+ document.querySelector('[type="submit"]').addEventListener("click", resetInput);
47
+ </script>
48
+ """
49
+
50
+ interface.infer = lambda x: (x[0], x[1], reset_input())
51
 
52
  interface.launch(debug=True)