Spaces:
Sleeping
Sleeping
update some CTA messages
Browse files
app.py
CHANGED
@@ -80,8 +80,8 @@ def chat_with_bot(input_text, history, conversation_times, valence_scores, arous
|
|
80 |
valence, arousal, conversation_times, valence_scores, arousal_scores = analyze_sentiment_corpus(input_text, conversation_times, valence_scores, arousal_scores)
|
81 |
|
82 |
# 判斷是否建議放鬆練習
|
83 |
-
if
|
84 |
-
response = "
|
85 |
history.append((input_text, response))
|
86 |
med_confirm_layout = True
|
87 |
return history, med_confirm_layout, jump2med_btn, conversation_times, valence_scores, arousal_scores, meditation_flag
|
@@ -115,7 +115,7 @@ def generate_images(history, conversation_times, last_genimg_times, generated_im
|
|
115 |
user_story = " ".join([h[0] for h in history])
|
116 |
prompt = translate_to_english(user_story)
|
117 |
|
118 |
-
neg_prompt = "realistic, camera,
|
119 |
|
120 |
seeds = np.random.randint(0, 100000, 4)
|
121 |
generator = [torch.Generator().manual_seed(int(i)) for i in seeds]
|
@@ -176,7 +176,7 @@ def handle_chat(input_text, history, conversation_times, valence_scores, arousal
|
|
176 |
if meditation:
|
177 |
return (
|
178 |
updated_history,
|
179 |
-
gr.update(value="", placeholder="
|
180 |
gr.update(visible=False), # submit
|
181 |
gr.update(visible=False), # jump_to_med
|
182 |
gr.update(visible=True), # meditation_buttons
|
@@ -291,7 +291,7 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
291 |
|
292 |
loading_message = gr.Textbox(visible=False, show_label=False)
|
293 |
with gr.Column(visible=False) as audio_interface:
|
294 |
-
audio_player = gr.Audio(label="
|
295 |
back_to_chat = gr.Button("返回聊天")
|
296 |
|
297 |
with gr.Row() as main_interface:
|
@@ -300,7 +300,7 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
300 |
msg = gr.Textbox(show_label=False, placeholder="今天想要跟我分享什麼呢?", autofocus=True, scale=2)
|
301 |
with gr.Row():
|
302 |
submit = gr.Button("送出", variant="primary", scale=2)
|
303 |
-
jump_to_med = gr.Button("
|
304 |
gen_other_img = gr.Button("結合聯想生成更多圖像", variant="secondary", scale=2, visible=False)
|
305 |
clear = gr.Button("清除對話紀錄", scale=1)
|
306 |
with gr.Row(visible=False) as meditation_buttons:
|
@@ -340,5 +340,5 @@ with gr.Blocks(theme=theme, css=css) as demo:
|
|
340 |
gen_other_img.click(generate_images, [chatbot, conversation_times, last_genimg_times, generated_images], [conversation_times, last_genimg_times] + image_outputs)
|
341 |
|
342 |
if __name__ == "__main__":
|
343 |
-
demo.queue(max_size=
|
344 |
demo.launch(show_api=False)
|
|
|
80 |
valence, arousal, conversation_times, valence_scores, arousal_scores = analyze_sentiment_corpus(input_text, conversation_times, valence_scores, arousal_scores)
|
81 |
|
82 |
# 判斷是否建議放鬆練習
|
83 |
+
if 4 <= arousal <= 5 and meditation_flag is True: # 詢問是否進行放鬆練習
|
84 |
+
response = "我知道你的狀況了\n我有一個建議,我們來進行一個可以讓自己放鬆的呼吸練習好嗎?"
|
85 |
history.append((input_text, response))
|
86 |
med_confirm_layout = True
|
87 |
return history, med_confirm_layout, jump2med_btn, conversation_times, valence_scores, arousal_scores, meditation_flag
|
|
|
115 |
user_story = " ".join([h[0] for h in history])
|
116 |
prompt = translate_to_english(user_story)
|
117 |
|
118 |
+
neg_prompt = "dark, realistic, camera, words, sentence, text, Low quality, error, blurry, deformed, extra, nude, duplicate, ugly"
|
119 |
|
120 |
seeds = np.random.randint(0, 100000, 4)
|
121 |
generator = [torch.Generator().manual_seed(int(i)) for i in seeds]
|
|
|
176 |
if meditation:
|
177 |
return (
|
178 |
updated_history,
|
179 |
+
gr.update(value="", placeholder="現在開始引導放鬆吧", interactive=False), # msg
|
180 |
gr.update(visible=False), # submit
|
181 |
gr.update(visible=False), # jump_to_med
|
182 |
gr.update(visible=True), # meditation_buttons
|
|
|
291 |
|
292 |
loading_message = gr.Textbox(visible=False, show_label=False)
|
293 |
with gr.Column(visible=False) as audio_interface:
|
294 |
+
audio_player = gr.Audio(label="放鬆引導指導語", show_download_button=False, interactive=False)
|
295 |
back_to_chat = gr.Button("返回聊天")
|
296 |
|
297 |
with gr.Row() as main_interface:
|
|
|
300 |
msg = gr.Textbox(show_label=False, placeholder="今天想要跟我分享什麼呢?", autofocus=True, scale=2)
|
301 |
with gr.Row():
|
302 |
submit = gr.Button("送出", variant="primary", scale=2)
|
303 |
+
jump_to_med = gr.Button("跳過對話進行放鬆引導", variant="secondary", scale=2)
|
304 |
gen_other_img = gr.Button("結合聯想生成更多圖像", variant="secondary", scale=2, visible=False)
|
305 |
clear = gr.Button("清除對話紀錄", scale=1)
|
306 |
with gr.Row(visible=False) as meditation_buttons:
|
|
|
340 |
gen_other_img.click(generate_images, [chatbot, conversation_times, last_genimg_times, generated_images], [conversation_times, last_genimg_times] + image_outputs)
|
341 |
|
342 |
if __name__ == "__main__":
|
343 |
+
demo.queue(max_size=30)
|
344 |
demo.launch(show_api=False)
|