douglarek commited on
Commit
d3f72ee
1 Parent(s): a4b430d

feat: add clear button;

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -31,6 +31,7 @@ chatbot_component = gr.Chatbot(
31
  )
32
  text_prompt_component = gr.Textbox(placeholder="Hi there! [press Enter]", show_label=False, autofocus=True, scale=8)
33
  run_button_component = gr.Button(value="Run", variant="primary", scale=1)
 
34
  mistral_key_component = gr.Textbox(
35
  label="MISTRAL API KEY",
36
  value="",
@@ -124,6 +125,7 @@ with gr.Blocks() as demo:
124
  with gr.Row():
125
  text_prompt_component.render()
126
  run_button_component.render()
 
127
  with gr.Accordion("Parameters", open=False):
128
  model_component.render()
129
  temperature_component.render()
@@ -134,7 +136,7 @@ with gr.Blocks() as demo:
134
  inputs=bot_inputs,
135
  outputs=[chatbot_component],
136
  )
137
-
138
  text_prompt_component.submit(
139
  fn=user, inputs=user_inputs, outputs=[text_prompt_component, chatbot_component], queue=False
140
  ).then(
 
31
  )
32
  text_prompt_component = gr.Textbox(placeholder="Hi there! [press Enter]", show_label=False, autofocus=True, scale=8)
33
  run_button_component = gr.Button(value="Run", variant="primary", scale=1)
34
+ clear_button_component = gr.ClearButton(value="Clear", variant="secondary", scale=1)
35
  mistral_key_component = gr.Textbox(
36
  label="MISTRAL API KEY",
37
  value="",
 
125
  with gr.Row():
126
  text_prompt_component.render()
127
  run_button_component.render()
128
+ clear_button_component.render()
129
  with gr.Accordion("Parameters", open=False):
130
  model_component.render()
131
  temperature_component.render()
 
136
  inputs=bot_inputs,
137
  outputs=[chatbot_component],
138
  )
139
+ clear_button_component.click(lambda: (None, None), outputs=[text_prompt_component, chatbot_component], queue=False)
140
  text_prompt_component.submit(
141
  fn=user, inputs=user_inputs, outputs=[text_prompt_component, chatbot_component], queue=False
142
  ).then(