code-slicer commited on
Commit
30c934b
Β·
verified Β·
1 Parent(s): e2b6c84

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -47
app.py CHANGED
@@ -1452,34 +1452,30 @@ def main():
1452
  st.session_state["user_input_rendered"] = True
1453
 
1454
  if user_input:
1455
- # 2) mode 탐지
1456
- _, _, mode = detect_location_filter(user_input)
1457
- top_emotions, emotion_groups = analyze_emotion(user_input)
1458
  intent, intent_score = detect_intent(user_input)
1459
- country_filter, city_filter, _ = detect_location_filter(user_input)
1460
- candidate_themes = extract_themes(
1461
- emotion_groups,
1462
- intent,
1463
- force_mode=(intent_score >= 0.70)
1464
- )
1465
- if intent_score >= 0.70:
 
 
1466
  mode = "intent"
1467
-
1468
- # 🌟 DEBUG ────────────────────────────────
1469
- # with st.expander("πŸ” DEBUG - λͺ¨λ“œ νŒμ •", expanded=True):
1470
- # st.markdown(f"""
1471
- # **μž…λ ₯ λ¬Έμž₯**: `{user_input}`
1472
- # **detect_location_filter** πŸ‘‰
1473
- # β€’ country β†’ `{country_filter}`
1474
- # β€’ city     β†’ `{city_filter}`
1475
- # β€’ mode  β†’ `{mode}`
1476
-
1477
- # **intent_score**: `{intent_score:.3f}`
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