Chanjeans commited on
Commit
9c45e5d
Β·
verified Β·
1 Parent(s): e219760

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -23
app.py CHANGED
@@ -1262,28 +1262,7 @@ def chat_or_recommend(req: ChatOrRecommendRequest):
1262
  )
1263
 
1264
  is_recommend_query = any(keyword in req.user_input for keyword in RECOMMEND_KEYWORDS)
1265
- # 2) μΆ”μ²œ μš”μ²­μΈ 경우 β†’ μΆ”μ²œλ§Œ μˆ˜ν–‰
1266
- if is_recommend_query:
1267
- user_profile = {
1268
- "extroversion": req.extroversion or "",
1269
- "feeling_thinking": req.feeling_thinking or "",
1270
- "hobby": req.hobby or [],
1271
- "detail_hobby": req.detail_hobby or [],
1272
- }
1273
- top_items = recommend_content_based(user_profile, top_n=5)
1274
-
1275
- recommendation_msg = "당신을 μœ„ν•œ 맞좀 μΆ”μ²œμ„ κ°€μ Έμ™”μ–΄μš”! ☺️"
1276
- for i, (item, score) in enumerate(top_items, start=1):
1277
- recommendations_list.append({
1278
- "item_id": item["item_id"],
1279
- "title": item["title"],
1280
- "desc": item["desc"],
1281
- "personality": item["personality"],
1282
- "score": round(score, 4)
1283
- })
1284
- clean_desc = re.sub(r"\(.*?\)", "", item["desc"]).strip()
1285
- recommendation_msg += f"{i}. **{item['title']}** - {clean_desc}"
1286
- recommendation_msg += "이 μ€‘μ—μ„œ μ–΄λ–€ ν™œλ™μ΄ κ°€μž₯ λŒλ¦¬μ‹œλ‚˜μš”? 🌟"
1287
 
1288
  # 항상 챗봇 λ©”μ‹œμ§€ 생성 (emotion λ˜λŠ” rational λͺ¨λ“œ)
1289
  mode = req.mode.lower()
@@ -1297,7 +1276,7 @@ def chat_or_recommend(req: ChatOrRecommendRequest):
1297
  # μš°μšΈλ„κ°€ "상담 ꢌμž₯"이 μ•„λ‹Œ κ²½μš°μ—λ§Œ μΆ”μ²œ λ©”μ‹œμ§€ 생성
1298
  recommendation_msg = ""
1299
  recommendations_list = []
1300
- if depression_label != "상담 ꢌμž₯" and req.hobby:
1301
  user_profile = {
1302
  "extroversion": req.extroversion or "",
1303
  "feeling_thinking": req.feeling_thinking or "",
@@ -1319,10 +1298,12 @@ def chat_or_recommend(req: ChatOrRecommendRequest):
1319
  recommendation_msg += "이 μ€‘μ—μ„œ μ–΄λ–€ ν™œλ™μ΄ κ°€μž₯ λŒλ¦¬μ‹œλ‚˜μš”? 🌟"
1320
 
1321
  # μ΅œμ’… 응닡 κ²°ν•©
 
1322
  final_response = counseling_response + chatbot_msg
1323
  if recommendation_msg:
1324
  final_response += "" + recommendation_msg
1325
 
 
1326
  response_dict = {
1327
  "mode": "chat+recommend" if recommendation_msg else "chat",
1328
  "response": final_response,
 
1262
  )
1263
 
1264
  is_recommend_query = any(keyword in req.user_input for keyword in RECOMMEND_KEYWORDS)
1265
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1266
 
1267
  # 항상 챗봇 λ©”μ‹œμ§€ 생성 (emotion λ˜λŠ” rational λͺ¨λ“œ)
1268
  mode = req.mode.lower()
 
1276
  # μš°μšΈλ„κ°€ "상담 ꢌμž₯"이 μ•„λ‹Œ κ²½μš°μ—λ§Œ μΆ”μ²œ λ©”μ‹œμ§€ 생성
1277
  recommendation_msg = ""
1278
  recommendations_list = []
1279
+ if depression_label != "상담 ꢌμž₯" and req.hobby and is_recommend_query:
1280
  user_profile = {
1281
  "extroversion": req.extroversion or "",
1282
  "feeling_thinking": req.feeling_thinking or "",
 
1298
  recommendation_msg += "이 μ€‘μ—μ„œ μ–΄λ–€ ν™œλ™μ΄ κ°€μž₯ λŒλ¦¬μ‹œλ‚˜μš”? 🌟"
1299
 
1300
  # μ΅œμ’… 응닡 κ²°ν•©
1301
+
1302
  final_response = counseling_response + chatbot_msg
1303
  if recommendation_msg:
1304
  final_response += "" + recommendation_msg
1305
 
1306
+
1307
  response_dict = {
1308
  "mode": "chat+recommend" if recommendation_msg else "chat",
1309
  "response": final_response,