Spaces:
Running
Running
Update app.py
Browse files
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 |
-
#
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
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)
|