Update app.py
Browse files
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"]:
|