Upload database.py
Browse files- Akeno/utils/database.py +12 -2
Akeno/utils/database.py
CHANGED
@@ -600,9 +600,9 @@ class Database:
|
|
600 |
unset_clear = {"cohere_chat": None}
|
601 |
return await self.cohere.update_one({"user_id": user_id}, {"$unset": unset_clear})
|
602 |
|
603 |
-
async def clear_database(self):
|
604 |
"""Clear the cohere history for the current user."""
|
605 |
-
result = await self._clear_history_in_db()
|
606 |
if result.modified_count > 0:
|
607 |
return "Chat history cleared successfully."
|
608 |
else:
|
@@ -647,5 +647,15 @@ class Database:
|
|
647 |
user_data = await self.backup_chatbot.find_one({"user_id": user_id})
|
648 |
return user_data.get("chatbot_chat", []) if user_data else []
|
649 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
650 |
|
651 |
db = Database(MONGO_URL)
|
|
|
600 |
unset_clear = {"cohere_chat": None}
|
601 |
return await self.cohere.update_one({"user_id": user_id}, {"$unset": unset_clear})
|
602 |
|
603 |
+
async def clear_database(self, user_id):
|
604 |
"""Clear the cohere history for the current user."""
|
605 |
+
result = await self._clear_history_in_db(user_id)
|
606 |
if result.modified_count > 0:
|
607 |
return "Chat history cleared successfully."
|
608 |
else:
|
|
|
647 |
user_data = await self.backup_chatbot.find_one({"user_id": user_id})
|
648 |
return user_data.get("chatbot_chat", []) if user_data else []
|
649 |
|
650 |
+
async def _clear_chatbot_history_in_db(self, user_id):
|
651 |
+
unset_clear = {"chatbot_chat": None}
|
652 |
+
return await self.backup_chatbot.update_one({"user_id": user_id}, {"$unset": unset_clear})
|
653 |
+
|
654 |
+
async def _clear_chatbot_database(self, user_id):
|
655 |
+
result = await self._clear_chatbot_history_in_db(user_id)
|
656 |
+
if result.modified_count > 0:
|
657 |
+
return "Chat history cleared successfully."
|
658 |
+
else:
|
659 |
+
return "No chat history found to clear."
|
660 |
|
661 |
db = Database(MONGO_URL)
|