Spaces:
Paused
Paused
move Regenerate and clear button to bottom
Browse files
app.py
CHANGED
|
@@ -204,7 +204,12 @@ def clear_button_clicked(_question, _chat_bot, _app_cfg, _bt_pic):
|
|
| 204 |
|
| 205 |
with gr.Blocks() as demo:
|
| 206 |
with gr.Row():
|
| 207 |
-
with gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
params_form = create_component(form_radio, comp='Radio')
|
| 209 |
with gr.Accordion("Beam Search", visible=False) as beams_according:
|
| 210 |
num_beams = create_component(num_beams_slider)
|
|
@@ -216,29 +221,24 @@ with gr.Blocks() as demo:
|
|
| 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 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
|
| 243 |
# launch
|
| 244 |
#demo.launch(share=False, debug=True, show_api=False, server_port=8080, server_name="0.0.0.0")
|
|
|
|
| 204 |
|
| 205 |
with gr.Blocks() as demo:
|
| 206 |
with gr.Row():
|
| 207 |
+
with gr.Row(scale=1, min_width=500):
|
| 208 |
+
app_session = gr.State({'sts':None,'ctx':None,'img':None})
|
| 209 |
+
bt_pic = gr.Image(label="Upload an image to start")
|
| 210 |
+
chat_bot = gr.Chatbot(label=f"Chat with {model_name}")
|
| 211 |
+
txt_message = gr.Textbox(label="Input text")
|
| 212 |
+
with gr.Row(scale=1, min_width=300):
|
| 213 |
params_form = create_component(form_radio, comp='Radio')
|
| 214 |
with gr.Accordion("Beam Search", visible=False) as beams_according:
|
| 215 |
num_beams = create_component(num_beams_slider)
|
|
|
|
| 221 |
repetition_penalty_2 = create_component(repetition_penalty_slider2)
|
| 222 |
regenerate = create_component({'value': 'Regenerate'}, comp='Button', visible=True)
|
| 223 |
clear = create_component({'value': 'Clear'}, comp='Button', visible=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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],
|
| 234 |
+
[txt_message, chat_bot, app_session]
|
| 235 |
+
)
|
| 236 |
+
txt_message.submit(
|
| 237 |
+
respond,
|
| 238 |
+
[txt_message, chat_bot, app_session, params_form, num_beams, repetition_penalty, repetition_penalty_2, top_p, top_k, temperature],
|
| 239 |
+
[txt_message, chat_bot, app_session]
|
| 240 |
+
)
|
| 241 |
+
bt_pic.upload(lambda: None, None, chat_bot, queue=False).then(upload_img, inputs=[bt_pic,chat_bot,app_session], outputs=[chat_bot,app_session])
|
| 242 |
|
| 243 |
# launch
|
| 244 |
#demo.launch(share=False, debug=True, show_api=False, server_port=8080, server_name="0.0.0.0")
|