Upload 2 files
Browse files- app.py +12 -9
- user_profiles.json +27 -1
app.py
CHANGED
@@ -508,6 +508,17 @@ def chatbot_fn(user_message, history, image=None):
|
|
508 |
final_response = extract_product_info_for_gallery(partial_response)
|
509 |
yield final_response
|
510 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
511 |
# Log: Asistan cevabını ekle
|
512 |
try:
|
513 |
with file_lock:
|
@@ -869,15 +880,7 @@ with gr.Blocks(css=custom_css, theme="soft", title="Trek Asistanı") as demo:
|
|
869 |
chat_history = []
|
870 |
chat_history.append((message, response))
|
871 |
|
872 |
-
#
|
873 |
-
try:
|
874 |
-
profile_manager.add_interaction(session_state['session_id'], "chat_message", {
|
875 |
-
"user_message": message,
|
876 |
-
"bot_response": response,
|
877 |
-
"timestamp": time.strftime("%Y-%m-%d %H:%M:%S")
|
878 |
-
})
|
879 |
-
except Exception as e:
|
880 |
-
print(f"Profile chat save error: {e}")
|
881 |
|
882 |
return "", chat_history, session_state
|
883 |
|
|
|
508 |
final_response = extract_product_info_for_gallery(partial_response)
|
509 |
yield final_response
|
510 |
|
511 |
+
# Kullanıcı profiline normal sohbet kaydet
|
512 |
+
try:
|
513 |
+
user_id = getattr(chatbot_fn, '_current_session_id', 'default_user')
|
514 |
+
profile_manager.add_interaction(user_id, "chat_message", {
|
515 |
+
"user_message": user_message,
|
516 |
+
"bot_response": partial_response,
|
517 |
+
"timestamp": time.strftime("%Y-%m-%d %H:%M:%S")
|
518 |
+
})
|
519 |
+
except Exception as e:
|
520 |
+
print(f"Profile normal chat save error: {e}")
|
521 |
+
|
522 |
# Log: Asistan cevabını ekle
|
523 |
try:
|
524 |
with file_lock:
|
|
|
880 |
chat_history = []
|
881 |
chat_history.append((message, response))
|
882 |
|
883 |
+
# Profile kaydetme chatbot_fn içinde yapılıyor, burada duplikasyon yok
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
884 |
|
885 |
return "", chat_history, session_state
|
886 |
|
user_profiles.json
CHANGED
@@ -1 +1,27 @@
|
|
1 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"test_12345": {
|
3 |
+
"created_at": "2025-07-15T02:35:29.066896",
|
4 |
+
"preferences": {
|
5 |
+
"budget_range": [
|
6 |
+
50000,
|
7 |
+
75000
|
8 |
+
],
|
9 |
+
"bike_category": "dağ bisikleti",
|
10 |
+
"size": null,
|
11 |
+
"usage_purpose": "spor ve egzersiz"
|
12 |
+
},
|
13 |
+
"interaction_history": [
|
14 |
+
{
|
15 |
+
"timestamp": "2025-07-15T02:35:29.066898",
|
16 |
+
"type": "chat_message",
|
17 |
+
"data": {
|
18 |
+
"user_message": "50k bütçeyle dağ bisikleti arıyorum spor için",
|
19 |
+
"bot_response": "Marlin önerebilirim",
|
20 |
+
"timestamp": "2025-07-15T02:35:29.066885"
|
21 |
+
}
|
22 |
+
}
|
23 |
+
],
|
24 |
+
"favorite_products": [],
|
25 |
+
"viewed_products": []
|
26 |
+
}
|
27 |
+
}
|