Spaces:
Sleeping
Sleeping
Commit
·
6431123
1
Parent(s):
52b54a6
Update api_routes_v2.py
Browse files- api_routes_v2.py +5 -3
api_routes_v2.py
CHANGED
|
@@ -86,11 +86,13 @@ def _save_conversation_to_s3(session_id: str, messages: List[Dict[str, Any]]):
|
|
| 86 |
Body=json.dumps(messages, ensure_ascii=False),
|
| 87 |
ContentType="application/json"
|
| 88 |
)
|
| 89 |
-
# Update MongoDB with reference (idempotent)
|
| 90 |
session_manager.update_session(session_id, {
|
| 91 |
"conversation_s3_key": key,
|
| 92 |
"last_message_count": len(messages),
|
| 93 |
-
"
|
|
|
|
|
|
|
| 94 |
})
|
| 95 |
except Exception as e:
|
| 96 |
print(f"CRITICAL ERROR saving conversation to S3: {e}")
|
|
@@ -819,7 +821,7 @@ async def get_all_sessions(
|
|
| 819 |
# REMOVED: current_file (not needed for session list)
|
| 820 |
"chat_name": session.get("chat_name"), # CHANGE: added field
|
| 821 |
"stats": session.get("stats", {}),
|
| 822 |
-
"total_messages":
|
| 823 |
"pipeline_executions_count": len(session.get("pipeline_executions", []))
|
| 824 |
})
|
| 825 |
|
|
|
|
| 86 |
Body=json.dumps(messages, ensure_ascii=False),
|
| 87 |
ContentType="application/json"
|
| 88 |
)
|
| 89 |
+
# Update MongoDB with reference and stats (idempotent)
|
| 90 |
session_manager.update_session(session_id, {
|
| 91 |
"conversation_s3_key": key,
|
| 92 |
"last_message_count": len(messages),
|
| 93 |
+
"last_activity": datetime.utcnow().isoformat() + "Z",
|
| 94 |
+
"last_updated": datetime.utcnow().isoformat() + "Z",
|
| 95 |
+
"stats.message_count": len(messages)
|
| 96 |
})
|
| 97 |
except Exception as e:
|
| 98 |
print(f"CRITICAL ERROR saving conversation to S3: {e}")
|
|
|
|
| 821 |
# REMOVED: current_file (not needed for session list)
|
| 822 |
"chat_name": session.get("chat_name"), # CHANGE: added field
|
| 823 |
"stats": session.get("stats", {}),
|
| 824 |
+
"total_messages": session.get("last_message_count", 0),
|
| 825 |
"pipeline_executions_count": len(session.get("pipeline_executions", []))
|
| 826 |
})
|
| 827 |
|