Chanjeans commited on
Commit
87d4513
ยท
verified ยท
1 Parent(s): 2b154d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -1056,7 +1056,7 @@ def recommend_content_based(user_profile, top_n=5):
1056
  # [detail_hobby] ๊ฐ ์š”์†Œ๊ฐ€ desc_hobby์— ์žˆ์œผ๋ฉด ๊ฐ€์ค‘์น˜ ๋ถ€์—ฌ
1057
  for dh in user_details:
1058
  if dh in desc_hobby:
1059
- weight *= 1.2
1060
 
1061
  # (2) ์„ฑํ–ฅ
1062
  # ์„ฑํ–ฅ 2๊ฐœ(์™ธํ–ฅํ˜•/๋‚ดํ–ฅํ˜•, ๊ฐ์ •ํ˜•/์ด์„ฑํ˜•) ์ค‘ ๋ช‡ ๊ฐœ๊ฐ€ ๋งค์นญ๋˜๋Š”์ง€
@@ -1067,7 +1067,7 @@ def recommend_content_based(user_profile, top_n=5):
1067
  if personality_match_count == 1:
1068
  weight *= 1.15
1069
  elif personality_match_count == 2:
1070
- weight *= 1.3
1071
 
1072
  final_score = sim * weight
1073
  scored.append((item, final_score))
@@ -1211,7 +1211,15 @@ def chat_or_recommend(req: ChatOrRecommendRequest):
1211
  "personality": item["personality"],
1212
  "score": round(score, 4)
1213
  })
1214
- return {"mode": "recommend", "recommendations": results}
 
 
 
 
 
 
 
 
1215
 
1216
  else:
1217
  # โ–ถ 2) ์ฑ—๋ด‡ ๋กœ์ง
 
1056
  # [detail_hobby] ๊ฐ ์š”์†Œ๊ฐ€ desc_hobby์— ์žˆ์œผ๋ฉด ๊ฐ€์ค‘์น˜ ๋ถ€์—ฌ
1057
  for dh in user_details:
1058
  if dh in desc_hobby:
1059
+ weight *= 1.3
1060
 
1061
  # (2) ์„ฑํ–ฅ
1062
  # ์„ฑํ–ฅ 2๊ฐœ(์™ธํ–ฅํ˜•/๋‚ดํ–ฅํ˜•, ๊ฐ์ •ํ˜•/์ด์„ฑํ˜•) ์ค‘ ๋ช‡ ๊ฐœ๊ฐ€ ๋งค์นญ๋˜๋Š”์ง€
 
1067
  if personality_match_count == 1:
1068
  weight *= 1.15
1069
  elif personality_match_count == 2:
1070
+ weight *= 1.25
1071
 
1072
  final_score = sim * weight
1073
  scored.append((item, final_score))
 
1211
  "personality": item["personality"],
1212
  "score": round(score, 4)
1213
  })
1214
+ # โ‘  ๋ถ€๋“œ๋Ÿฌ์šด ๋Œ€ํ™”์ฒด๋กœ ๊ฐ€๊ณต
1215
+ response_text = "๋‹น์‹ ์„ ์œ„ํ•œ ๋งž์ถค ์ถ”์ฒœ์„ ๊ฐ€์ ธ์™”์–ด์š”! โ˜บ๏ธ\n\n"
1216
+ for i, (item, score) in enumerate(top_items, start=1):
1217
+ response_text += (
1218
+ f"{i}. **{item['title']}**\n"
1219
+ f" - {item['desc']}\n"
1220
+ )
1221
+ response_text += "\n์ด ์ค‘์—์„œ ์–ด๋–ค ํ™œ๋™์ด ๊ฐ€์žฅ ๋Œ๋ฆฌ์‹œ๋‚˜์š”? ๐ŸŒŸ"
1222
+ return {"mode": "recommend", "recommendations": results, response_text}
1223
 
1224
  else:
1225
  # โ–ถ 2) ์ฑ—๋ด‡ ๋กœ์ง