ShermanAI commited on
Commit
cd79030
·
1 Parent(s): 2d0b89c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -5
app.py CHANGED
@@ -23,16 +23,27 @@ def openai_chat(prompt):
23
  def chatbot(talk_to_chatsherman, history=[]):
24
  output = openai_chat(talk_to_chatsherman)
25
  history.append((talk_to_chatsherman, output))
26
- return history, history, True
27
 
28
  title = "ChatSherman"
29
  description = "This is an AI chatbot powered by ShermanAI."
30
  examples = [
31
- ["What is the difference between a resistor and a capacitor?", [], False],
32
- ["Can you explain the concept of electrical conductivity?", [], False],
33
- ["How do you calculate the force required to move an object?", [], False]
34
  ]
35
  inputs = [gr.inputs.Textbox(label="Enter your question: "), "state"]
36
- outputs = ["chatbot", "state", gr.outputs.Toggle(label="Clear input")]
37
  interface = gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title=title, description=description, examples=examples)
 
 
 
 
 
 
 
 
 
 
 
38
  interface.launch(debug=True)
 
23
  def chatbot(talk_to_chatsherman, history=[]):
24
  output = openai_chat(talk_to_chatsherman)
25
  history.append((talk_to_chatsherman, output))
26
+ return history, history
27
 
28
  title = "ChatSherman"
29
  description = "This is an AI chatbot powered by ShermanAI."
30
  examples = [
31
+ ["What is the difference between a resistor and a capacitor?", []],
32
+ ["Can you explain the concept of electrical conductivity?", []],
33
+ ["How do you calculate the force required to move an object?", []]
34
  ]
35
  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.script("""
41
+ function resetInput() {
42
+ document.getElementById("input-textbox").value = "";
43
+ }
44
+ """)
45
+
46
+ # Call the resetInput function when the user submits a question
47
+ interface.layout.submit_button.onclick = "resetInput();"
48
+
49
  interface.launch(debug=True)