Spaces:
Paused
Paused
Add clear history
Browse files
app.py
CHANGED
@@ -193,6 +193,14 @@ def regenerate_button_clicked(_question, _chat_bot, _app_cfg, params_form, num_b
|
|
193 |
return respond(_question, _chat_bot, _app_cfg, params_form, num_beams, repetition_penalty, repetition_penalty_2, top_p, top_k, temperature)
|
194 |
|
195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
|
197 |
with gr.Blocks() as demo:
|
198 |
with gr.Row():
|
@@ -207,12 +215,19 @@ with gr.Blocks() as demo:
|
|
207 |
temperature = create_component(temperature_slider)
|
208 |
repetition_penalty_2 = create_component(repetition_penalty_slider2)
|
209 |
regenerate = create_component({'value': 'Regenerate'}, comp='Button', visible=True)
|
|
|
210 |
with gr.Column(scale=3, min_width=500):
|
211 |
app_session = gr.State({'sts':None,'ctx':None,'img':None})
|
212 |
bt_pic = gr.Image(label="Upload an image to start")
|
213 |
chat_bot = gr.Chatbot(label=f"Chat with {model_name}")
|
214 |
txt_message = gr.Textbox(label="Input text")
|
215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
regenerate.click(
|
217 |
regenerate_button_clicked,
|
218 |
[txt_message, chat_bot, app_session, params_form, num_beams, repetition_penalty, repetition_penalty_2, top_p, top_k, temperature],
|
|
|
193 |
return respond(_question, _chat_bot, _app_cfg, params_form, num_beams, repetition_penalty, repetition_penalty_2, top_p, top_k, temperature)
|
194 |
|
195 |
|
196 |
+
def clear_button_clicked(_question, _chat_bot, _app_cfg, _bt_pic):
|
197 |
+
_chat_bot.clear()
|
198 |
+
_app_cfg['sts'] = None
|
199 |
+
_app_cfg['ctx'] = []
|
200 |
+
_app_cfg['img'] = None
|
201 |
+
_bt_pic = None
|
202 |
+
return '', _chat_bot, _app_cfg, _bt_pic
|
203 |
+
|
204 |
|
205 |
with gr.Blocks() as demo:
|
206 |
with gr.Row():
|
|
|
215 |
temperature = create_component(temperature_slider)
|
216 |
repetition_penalty_2 = create_component(repetition_penalty_slider2)
|
217 |
regenerate = create_component({'value': 'Regenerate'}, comp='Button', visible=True)
|
218 |
+
clear = create_component({'value': 'Clear'}, comp='Button', visible=True)
|
219 |
with gr.Column(scale=3, min_width=500):
|
220 |
app_session = gr.State({'sts':None,'ctx':None,'img':None})
|
221 |
bt_pic = gr.Image(label="Upload an image to start")
|
222 |
chat_bot = gr.Chatbot(label=f"Chat with {model_name}")
|
223 |
txt_message = gr.Textbox(label="Input text")
|
224 |
|
225 |
+
clear.click(
|
226 |
+
clear_button_clicked,
|
227 |
+
[txt_message, chat_bot, app_session, bt_pic],
|
228 |
+
[txt_message, chat_bot, app_session, bt_pic],
|
229 |
+
queue=False
|
230 |
+
)
|
231 |
regenerate.click(
|
232 |
regenerate_button_clicked,
|
233 |
[txt_message, chat_bot, app_session, params_form, num_beams, repetition_penalty, repetition_penalty_2, top_p, top_k, temperature],
|