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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py CHANGED
@@ -1261,6 +1261,30 @@ def chat_or_recommend(req: ChatOrRecommendRequest):
1261
  "λΉ λ₯Έ μ‹œμΌ 내에 전문가와 μƒλ‹΄ν•˜μ‹œκΈΈ λ°”λžλ‹ˆλ‹€."
1262
  )
1263
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1264
  # 항상 챗봇 λ©”μ‹œμ§€ 생성 (emotion λ˜λŠ” rational λͺ¨λ“œ)
1265
  mode = req.mode.lower()
1266
  if mode not in ["emotion", "rational"]:
 
1261
  "λΉ λ₯Έ μ‹œμΌ 내에 전문가와 μƒλ‹΄ν•˜μ‹œκΈΈ λ°”λžλ‹ˆλ‹€."
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()
1290
  if mode not in ["emotion", "rational"]: