Spaces:
Running
Running
Update ui.py
Browse files
ui.py
CHANGED
@@ -34,15 +34,21 @@ def create_ui():
|
|
34 |
|
35 |
analyze_button = gr.Button("分析情緒")
|
36 |
clear_button = gr.Button("清除")
|
37 |
-
progress_bar = gr.Textbox(value="",
|
38 |
|
39 |
result_output = gr.Markdown(label="分析結果")
|
40 |
|
41 |
# 📌 綁定按鈕功能
|
42 |
def process_analysis(text, model_name):
|
43 |
-
|
|
|
|
|
|
|
|
|
44 |
result, _ = analyze_sentiment(text, model_name)
|
45 |
-
progress_bar.
|
|
|
|
|
46 |
return result
|
47 |
|
48 |
analyze_button.click(
|
@@ -52,9 +58,9 @@ def create_ui():
|
|
52 |
)
|
53 |
|
54 |
clear_button.click(
|
55 |
-
lambda: ("", ""),
|
56 |
-
inputs=[],
|
57 |
-
outputs=[text_input,
|
58 |
)
|
59 |
|
60 |
gr.Markdown(developer_info)
|
|
|
34 |
|
35 |
analyze_button = gr.Button("分析情緒")
|
36 |
clear_button = gr.Button("清除")
|
37 |
+
progress_bar = gr.Textbox(value="等待輸入...", label="分析狀態") # 🚀 這裡改變名稱,並預設顯示文字
|
38 |
|
39 |
result_output = gr.Markdown(label="分析結果")
|
40 |
|
41 |
# 📌 綁定按鈕功能
|
42 |
def process_analysis(text, model_name):
|
43 |
+
print("📢 [Debug] 按鈕被點擊")
|
44 |
+
print(f"📢 [Debug] 模型: {model_name}")
|
45 |
+
print(f"📢 [Debug] 輸入文本: {text}")
|
46 |
+
|
47 |
+
progress_bar.value = "🔄 AI 模型載入中,請稍後..." # 🚀 直接修改 `Textbox` 值
|
48 |
result, _ = analyze_sentiment(text, model_name)
|
49 |
+
progress_bar.value = "✅ 分析完成" # 🚀 讓狀態顯示「分析完成」
|
50 |
+
|
51 |
+
print(f"📢 [Debug] 回傳結果: {result}")
|
52 |
return result
|
53 |
|
54 |
analyze_button.click(
|
|
|
58 |
)
|
59 |
|
60 |
clear_button.click(
|
61 |
+
lambda: ("", "等待輸入..."), # 🚀 修正清除功能,讓 progress_bar 也重置
|
62 |
+
inputs=[],
|
63 |
+
outputs=[text_input, progress_bar]
|
64 |
)
|
65 |
|
66 |
gr.Markdown(developer_info)
|