Spaces:
Sleeping
Sleeping
| from datetime import datetime, timezone | |
| from config import chat_collection | |
| def record_chat(user_message: str, bot_reply: str): | |
| doc = { | |
| "user_id": "Abhay122", | |
| "user_message": user_message, | |
| "bot_reply": bot_reply, | |
| "timestamp": datetime.now(timezone.utc), | |
| } | |
| try: | |
| chat_collection.insert_one(doc) | |
| return {"recorded": True} | |
| except Exception as e: | |
| print("⚠️ Skipping DB insert (Mongo not available):", e) | |
| return {"recorded": False} | |