yxmauw commited on
Commit
6b26f41
1 Parent(s): 25f5a36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -5,7 +5,11 @@ import json
5
  import time
6
  from load_llms import model_choices, llm_intro, load_model
7
 
 
 
 
8
 
 
9
  # Construct chatbot
10
  def generate_response(model_name, message, chat_history):
11
  model = load_model(model_name)
@@ -19,7 +23,7 @@ with gr.Blocks(
19
  "#chatbot { flex-grow: 1 !important; overflow: auto !important; }"
20
  "#col { height: calc(100vh - 112px - 16px) !important; }"
21
  "#submit:hover { background-color: green !important; }"
22
- "#clear_button { background-color: red !important; }",
23
  theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Martel Sans")])
24
  ) as demo:
25
  gr.Markdown("# GPT4All Chatbot")
@@ -46,7 +50,9 @@ with gr.Blocks(
46
  submit_button = gr.Button("Submit", scale=1, elem_id="submit")
47
  submit_button.click(generate_response, inputs=[model_dropdown, message, chatbot], outputs=[message, chatbot])
48
 
49
- clear = gr.ClearButton([message, chatbot], elem_id="clear_button")
 
 
50
 
51
  # Launch the Gradio app
52
  demo.launch()
 
5
  import time
6
  from load_llms import model_choices, llm_intro, load_model
7
 
8
+ def clear_output(message, chatbot):
9
+ message.update(value="")
10
+ chatbot.update(value="")
11
 
12
+
13
  # Construct chatbot
14
  def generate_response(model_name, message, chat_history):
15
  model = load_model(model_name)
 
23
  "#chatbot { flex-grow: 1 !important; overflow: auto !important; }"
24
  "#col { height: calc(100vh - 112px - 16px) !important; }"
25
  "#submit:hover { background-color: green !important; }"
26
+ "#clear:hover { background-color: red !important; }",
27
  theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Martel Sans")])
28
  ) as demo:
29
  gr.Markdown("# GPT4All Chatbot")
 
50
  submit_button = gr.Button("Submit", scale=1, elem_id="submit")
51
  submit_button.click(generate_response, inputs=[model_dropdown, message, chatbot], outputs=[message, chatbot])
52
 
53
+ # clear = gr.ClearButton([message, chatbot], elem_id="clear")
54
+ clear_button = gr.Button("Clear", elem_id="clear")
55
+ clear_button.click(clear_output, inputs=[message, chatbot], outputs=[message, chatbot])
56
 
57
  # Launch the Gradio app
58
  demo.launch()