Update app.py
Browse files
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 |
-
|
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,
|