Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1452,34 +1452,30 @@ def main():
|
|
| 1452 |
st.session_state["user_input_rendered"] = True
|
| 1453 |
|
| 1454 |
if user_input:
|
| 1455 |
-
#
|
| 1456 |
-
|
| 1457 |
-
top_emotions, emotion_groups = analyze_emotion(user_input)
|
| 1458 |
intent, intent_score = detect_intent(user_input)
|
| 1459 |
-
|
| 1460 |
-
|
| 1461 |
-
|
| 1462 |
-
|
| 1463 |
-
|
| 1464 |
-
|
| 1465 |
-
|
|
|
|
|
|
|
| 1466 |
mode = "intent"
|
| 1467 |
-
|
| 1468 |
-
|
| 1469 |
-
|
| 1470 |
-
|
| 1471 |
-
|
| 1472 |
-
|
| 1473 |
-
|
| 1474 |
-
|
| 1475 |
-
|
| 1476 |
-
|
| 1477 |
-
#
|
| 1478 |
-
# **top_emotions**: `{top_emotions}`
|
| 1479 |
-
# """)
|
| 1480 |
-
# ββββββββββββββββββββββββββββββββββββββββ
|
| 1481 |
-
|
| 1482 |
-
# 3) λͺ¨λλ³ λΆκΈ°
|
| 1483 |
if mode == "region":
|
| 1484 |
region_ui(
|
| 1485 |
travel_df,
|
|
@@ -1493,30 +1489,38 @@ def main():
|
|
| 1493 |
log_and_render
|
| 1494 |
)
|
| 1495 |
return
|
| 1496 |
-
|
| 1497 |
elif mode == "intent":
|
| 1498 |
intent_ui(
|
| 1499 |
-
travel_df,
|
| 1500 |
-
external_score_df,
|
| 1501 |
-
festival_df,
|
| 1502 |
-
weather_df,
|
| 1503 |
package_df,
|
| 1504 |
-
country_filter,
|
| 1505 |
-
city_filter,
|
| 1506 |
-
chat_container,
|
| 1507 |
-
intent,
|
| 1508 |
-
log_and_render
|
|
|
|
| 1509 |
return
|
| 1510 |
-
|
| 1511 |
-
elif mode == "unknown":
|
| 1512 |
unknown_ui(
|
| 1513 |
-
country_filter,
|
| 1514 |
-
city_filter,
|
| 1515 |
-
chat_container,
|
| 1516 |
-
log_and_render
|
|
|
|
| 1517 |
return
|
| 1518 |
-
|
| 1519 |
-
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1520 |
emotion_ui(
|
| 1521 |
travel_df,
|
| 1522 |
external_score_df,
|
|
@@ -1527,9 +1531,9 @@ def main():
|
|
| 1527 |
city_filter,
|
| 1528 |
chat_container,
|
| 1529 |
candidate_themes,
|
| 1530 |
-
intent,
|
| 1531 |
-
emotion_groups,
|
| 1532 |
-
top_emotions,
|
| 1533 |
log_and_render
|
| 1534 |
)
|
| 1535 |
|
|
|
|
| 1452 |
st.session_state["user_input_rendered"] = True
|
| 1453 |
|
| 1454 |
if user_input:
|
| 1455 |
+
# 1) μ λΉμ© λ¨κ³: μμΉ/μλ λ¨Όμ
|
| 1456 |
+
country_filter, city_filter, loc_mode = detect_location_filter(user_input)
|
|
|
|
| 1457 |
intent, intent_score = detect_intent(user_input)
|
| 1458 |
+
|
| 1459 |
+
# μ¬μ΄λλ°μμ μκ³κ°μ μΈ μ μκ² νλ€λ©΄, μμΌλ©΄ 0.70 κΈ°λ³Έ
|
| 1460 |
+
threshold = st.session_state.get("intent_threshold", 0.70)
|
| 1461 |
+
|
| 1462 |
+
# 2) λͺ¨λ κ²°μ : μ§μ νμ β intent νμ β unknown β (κ·Έ μΈ) emotion
|
| 1463 |
+
if loc_mode == "region":
|
| 1464 |
+
mode = "region"
|
| 1465 |
+
top_emotions, emotion_groups = [], []
|
| 1466 |
+
elif intent_score >= threshold:
|
| 1467 |
mode = "intent"
|
| 1468 |
+
top_emotions, emotion_groups = [], []
|
| 1469 |
+
elif loc_mode == "unknown":
|
| 1470 |
+
mode = "unknown"
|
| 1471 |
+
top_emotions, emotion_groups = [], []
|
| 1472 |
+
else:
|
| 1473 |
+
mode = "emotion"
|
| 1474 |
+
# 3) κ³ λΉμ© λ¨κ³: μ λ§ νμν λλ§ κ°μ±(BERT) μ€ν
|
| 1475 |
+
# with st.spinner("κ°μ λΆμ μ€..."): # UX μνμλ©΄ μ€νΌλ μΆκ°
|
| 1476 |
+
top_emotions, emotion_groups = analyze_emotion(user_input)
|
| 1477 |
+
|
| 1478 |
+
# 4) λͺ¨λλ³ λΆκΈ° (νμν κ³μ°λ§ μν)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1479 |
if mode == "region":
|
| 1480 |
region_ui(
|
| 1481 |
travel_df,
|
|
|
|
| 1489 |
log_and_render
|
| 1490 |
)
|
| 1491 |
return
|
| 1492 |
+
|
| 1493 |
elif mode == "intent":
|
| 1494 |
intent_ui(
|
| 1495 |
+
travel_df,
|
| 1496 |
+
external_score_df,
|
| 1497 |
+
festival_df,
|
| 1498 |
+
weather_df,
|
| 1499 |
package_df,
|
| 1500 |
+
country_filter,
|
| 1501 |
+
city_filter,
|
| 1502 |
+
chat_container,
|
| 1503 |
+
intent,
|
| 1504 |
+
log_and_render
|
| 1505 |
+
)
|
| 1506 |
return
|
| 1507 |
+
|
| 1508 |
+
elif mode == "unknown":
|
| 1509 |
unknown_ui(
|
| 1510 |
+
country_filter,
|
| 1511 |
+
city_filter,
|
| 1512 |
+
chat_container,
|
| 1513 |
+
log_and_render
|
| 1514 |
+
)
|
| 1515 |
return
|
| 1516 |
+
|
| 1517 |
+
else: # emotion
|
| 1518 |
+
# emotion λͺ¨λμμλ§ ν
λ§ μΆμΆ (λΆνμν κ³μ° λ°©μ§)
|
| 1519 |
+
candidate_themes = extract_themes(
|
| 1520 |
+
emotion_groups,
|
| 1521 |
+
intent,
|
| 1522 |
+
force_mode=False # intent νμ μΌμ΄μ€κ° μλλΌλ©΄ False
|
| 1523 |
+
)
|
| 1524 |
emotion_ui(
|
| 1525 |
travel_df,
|
| 1526 |
external_score_df,
|
|
|
|
| 1531 |
city_filter,
|
| 1532 |
chat_container,
|
| 1533 |
candidate_themes,
|
| 1534 |
+
intent,
|
| 1535 |
+
emotion_groups,
|
| 1536 |
+
top_emotions,
|
| 1537 |
log_and_render
|
| 1538 |
)
|
| 1539 |
|