Spaces:
Sleeping
Sleeping
remove clear button
Browse files
app.py
CHANGED
@@ -180,7 +180,6 @@ def handle_chat(input_text, history, conversation_times, valence_scores, arousal
|
|
180 |
gr.update(visible=False), # submit
|
181 |
gr.update(visible=False), # jump_to_med
|
182 |
gr.update(visible=True), # meditation_buttons
|
183 |
-
gr.update(visible=False), # clear
|
184 |
conversation_times, valence_scores, arousal_scores, meditation_flag
|
185 |
)
|
186 |
elif jump2med_btn is False:
|
@@ -190,7 +189,6 @@ def handle_chat(input_text, history, conversation_times, valence_scores, arousal
|
|
190 |
gr.update(visible=True), # submit
|
191 |
gr.update(visible=False), # jump_to_med
|
192 |
gr.update(visible=False), # meditation_buttons
|
193 |
-
gr.update(visible=True), # clear
|
194 |
conversation_times, valence_scores, arousal_scores, meditation_flag
|
195 |
)
|
196 |
else:
|
@@ -200,7 +198,6 @@ def handle_chat(input_text, history, conversation_times, valence_scores, arousal
|
|
200 |
gr.update(visible=True), # submit
|
201 |
gr.update(visible=True), # jump_to_med
|
202 |
gr.update(visible=False), # meditation_buttons
|
203 |
-
gr.update(visible=True), # clear
|
204 |
conversation_times, valence_scores, arousal_scores, meditation_flag
|
205 |
)
|
206 |
|
@@ -217,7 +214,6 @@ def continue_chat():
|
|
217 |
gr.update(visible=True), # submit
|
218 |
gr.update(visible=True), # jump_to_med
|
219 |
gr.update(visible=False), # meditation_buttons
|
220 |
-
gr.update(visible=True) # clear
|
221 |
)
|
222 |
|
223 |
def return_to_chat():
|
@@ -229,7 +225,6 @@ def return_to_chat():
|
|
229 |
gr.update(visible=False), # audio_interface
|
230 |
gr.update(interactive=True, placeholder="今天想跟我分享什麼呢?"), # msg
|
231 |
gr.update(visible=True), # submit
|
232 |
-
gr.update(visible=True), # clear
|
233 |
gr.update(visible=False), # meditation_buttons
|
234 |
gr.update(visible=True), # gen_other_img
|
235 |
gr.update(visible=False) # jump_to_med
|
@@ -303,7 +298,6 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
303 |
submit = gr.Button("送出", variant="primary", scale=2)
|
304 |
jump_to_med = gr.Button("跳過對話進行放鬆引導", variant="secondary", scale=2)
|
305 |
gen_other_img = gr.Button("結合聯想生成更多圖像", variant="secondary", scale=2, visible=False)
|
306 |
-
clear = gr.Button("清除對話紀錄", scale=1)
|
307 |
with gr.Row(visible=False) as meditation_buttons:
|
308 |
relax_yes = gr.Button("好", variant="primary")
|
309 |
relax_no = gr.Button("我想再多分享一點")
|
@@ -316,21 +310,20 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
316 |
image_chat_button = gr.Button("與聊天機器人分享", variant="primary")
|
317 |
|
318 |
# chatbot events handle
|
319 |
-
submit.click(handle_chat, [msg, chatbot, conversation_times, valence_scores, arousal_scores, meditation_flag], [chatbot, msg, submit, jump_to_med, meditation_buttons,
|
320 |
-
msg.submit(handle_chat, [msg, chatbot, conversation_times, valence_scores, arousal_scores, meditation_flag], [chatbot, msg, submit, jump_to_med, meditation_buttons,
|
321 |
-
clear.click(lambda: None, None, chatbot, queue=False)
|
322 |
|
323 |
# going to meditation events handle
|
324 |
jump_to_med.click(start_meditation, meditation_flag, [audio_player, meditation_flag])
|
325 |
relax_yes.click(start_meditation, meditation_flag, [audio_player, meditation_flag])
|
326 |
-
relax_no.click(continue_chat, None, [msg, submit, jump_to_med, meditation_buttons
|
327 |
|
328 |
# meditation events handle
|
329 |
jump_to_med.click(show_loading, None, [loading_message, loading_message, main_interface, audio_interface])
|
330 |
relax_yes.click(show_loading, None, [loading_message, loading_message, main_interface, audio_interface])
|
331 |
audio_player.play(generate_images, [chatbot, conversation_times, last_genimg_times, generated_images], [conversation_times, last_genimg_times] + image_outputs)
|
332 |
-
audio_player.stop(return_to_chat, None, [audio_player, main_interface, chatbot_interface, selected_image_interface, audio_interface, msg, submit,
|
333 |
-
back_to_chat.click(return_to_chat, None, [audio_player, main_interface, chatbot_interface, selected_image_interface, audio_interface, msg, submit,
|
334 |
|
335 |
# images select events handle
|
336 |
image_selector.change(select_image, [image_selector] + image_outputs, selected_image)
|
|
|
180 |
gr.update(visible=False), # submit
|
181 |
gr.update(visible=False), # jump_to_med
|
182 |
gr.update(visible=True), # meditation_buttons
|
|
|
183 |
conversation_times, valence_scores, arousal_scores, meditation_flag
|
184 |
)
|
185 |
elif jump2med_btn is False:
|
|
|
189 |
gr.update(visible=True), # submit
|
190 |
gr.update(visible=False), # jump_to_med
|
191 |
gr.update(visible=False), # meditation_buttons
|
|
|
192 |
conversation_times, valence_scores, arousal_scores, meditation_flag
|
193 |
)
|
194 |
else:
|
|
|
198 |
gr.update(visible=True), # submit
|
199 |
gr.update(visible=True), # jump_to_med
|
200 |
gr.update(visible=False), # meditation_buttons
|
|
|
201 |
conversation_times, valence_scores, arousal_scores, meditation_flag
|
202 |
)
|
203 |
|
|
|
214 |
gr.update(visible=True), # submit
|
215 |
gr.update(visible=True), # jump_to_med
|
216 |
gr.update(visible=False), # meditation_buttons
|
|
|
217 |
)
|
218 |
|
219 |
def return_to_chat():
|
|
|
225 |
gr.update(visible=False), # audio_interface
|
226 |
gr.update(interactive=True, placeholder="今天想跟我分享什麼呢?"), # msg
|
227 |
gr.update(visible=True), # submit
|
|
|
228 |
gr.update(visible=False), # meditation_buttons
|
229 |
gr.update(visible=True), # gen_other_img
|
230 |
gr.update(visible=False) # jump_to_med
|
|
|
298 |
submit = gr.Button("送出", variant="primary", scale=2)
|
299 |
jump_to_med = gr.Button("跳過對話進行放鬆引導", variant="secondary", scale=2)
|
300 |
gen_other_img = gr.Button("結合聯想生成更多圖像", variant="secondary", scale=2, visible=False)
|
|
|
301 |
with gr.Row(visible=False) as meditation_buttons:
|
302 |
relax_yes = gr.Button("好", variant="primary")
|
303 |
relax_no = gr.Button("我想再多分享一點")
|
|
|
310 |
image_chat_button = gr.Button("與聊天機器人分享", variant="primary")
|
311 |
|
312 |
# chatbot events handle
|
313 |
+
submit.click(handle_chat, [msg, chatbot, conversation_times, valence_scores, arousal_scores, meditation_flag], [chatbot, msg, submit, jump_to_med, meditation_buttons, conversation_times, valence_scores, arousal_scores, meditation_flag])
|
314 |
+
msg.submit(handle_chat, [msg, chatbot, conversation_times, valence_scores, arousal_scores, meditation_flag], [chatbot, msg, submit, jump_to_med, meditation_buttons, conversation_times, valence_scores, arousal_scores, meditation_flag])
|
|
|
315 |
|
316 |
# going to meditation events handle
|
317 |
jump_to_med.click(start_meditation, meditation_flag, [audio_player, meditation_flag])
|
318 |
relax_yes.click(start_meditation, meditation_flag, [audio_player, meditation_flag])
|
319 |
+
relax_no.click(continue_chat, None, [msg, submit, jump_to_med, meditation_buttons])
|
320 |
|
321 |
# meditation events handle
|
322 |
jump_to_med.click(show_loading, None, [loading_message, loading_message, main_interface, audio_interface])
|
323 |
relax_yes.click(show_loading, None, [loading_message, loading_message, main_interface, audio_interface])
|
324 |
audio_player.play(generate_images, [chatbot, conversation_times, last_genimg_times, generated_images], [conversation_times, last_genimg_times] + image_outputs)
|
325 |
+
audio_player.stop(return_to_chat, None, [audio_player, main_interface, chatbot_interface, selected_image_interface, audio_interface, msg, submit, meditation_buttons, gen_other_img, jump_to_med])
|
326 |
+
back_to_chat.click(return_to_chat, None, [audio_player, main_interface, chatbot_interface, selected_image_interface, audio_interface, msg, submit, meditation_buttons, gen_other_img, jump_to_med])
|
327 |
|
328 |
# images select events handle
|
329 |
image_selector.change(select_image, [image_selector] + image_outputs, selected_image)
|