Spaces:
Sleeping
Sleeping
Update ui.py
Browse files
ui.py
CHANGED
|
@@ -38,7 +38,7 @@ def create_ui():
|
|
| 38 |
|
| 39 |
analyze_button = gr.Button("ๅๆๆ
็ท")
|
| 40 |
clear_button = gr.Button("ๆธ
้ค")
|
| 41 |
-
result_display = gr.Markdown("็ญๅพ
่ผธๅ
ฅ...", label="AI ๅๆ") # ๐
|
| 42 |
|
| 43 |
# ๐ ็ถๅฎๆ้ๅ่ฝ
|
| 44 |
def process_analysis(text, model_name):
|
|
@@ -47,17 +47,21 @@ def create_ui():
|
|
| 47 |
print(f"๐ข [Debug] ่ผธๅ
ฅๆๆฌ: {text}")
|
| 48 |
|
| 49 |
processing_message = "๐ **AI ๆญฃๅจๅๆ๏ผ่ซ็จๅพ...**"
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
result, _ = analyze_sentiment(text, model_name)
|
| 53 |
|
|
|
|
|
|
|
| 54 |
print(f"๐ข [Debug] ๅๅณ็ตๆ: {result}")
|
| 55 |
-
return result # ๐
|
| 56 |
|
| 57 |
analyze_button.click(
|
| 58 |
fn=process_analysis,
|
| 59 |
inputs=[text_input, model_selector],
|
| 60 |
-
outputs=[result_display]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
)
|
| 62 |
|
| 63 |
clear_button.click(
|
|
|
|
| 38 |
|
| 39 |
analyze_button = gr.Button("ๅๆๆ
็ท")
|
| 40 |
clear_button = gr.Button("ๆธ
้ค")
|
| 41 |
+
result_display = gr.Markdown("็ญๅพ
่ผธๅ
ฅ...", label="AI ๅๆ") # ๐ ่ฎ `gr.Markdown()` ๆ็บ่ผธๅบๅ
|
| 42 |
|
| 43 |
# ๐ ็ถๅฎๆ้ๅ่ฝ
|
| 44 |
def process_analysis(text, model_name):
|
|
|
|
| 47 |
print(f"๐ข [Debug] ่ผธๅ
ฅๆๆฌ: {text}")
|
| 48 |
|
| 49 |
processing_message = "๐ **AI ๆญฃๅจๅๆ๏ผ่ซ็จๅพ...**"
|
| 50 |
+
return processing_message # ๐ ๅ
ๅๅณใๅๆไธญใ็่จๆฏ
|
|
|
|
|
|
|
| 51 |
|
| 52 |
+
def analyze_and_return(text, model_name):
|
| 53 |
+
result, _ = analyze_sentiment(text, model_name)
|
| 54 |
print(f"๐ข [Debug] ๅๅณ็ตๆ: {result}")
|
| 55 |
+
return result # ๐ ็ดๆฅๅๅณ็ตๆ
|
| 56 |
|
| 57 |
analyze_button.click(
|
| 58 |
fn=process_analysis,
|
| 59 |
inputs=[text_input, model_selector],
|
| 60 |
+
outputs=[result_display]
|
| 61 |
+
).then( # ๐ **็ญ็ฌฌไธๆญฅๅท่กๅฎๅพๅๅท่กๅๆ**
|
| 62 |
+
fn=analyze_and_return,
|
| 63 |
+
inputs=[text_input, model_selector],
|
| 64 |
+
outputs=[result_display]
|
| 65 |
)
|
| 66 |
|
| 67 |
clear_button.click(
|