chatgpt_telegram_bot
chatgpt_telegram_bot copied to clipboard
Automatically delete old dialogues from DB when initiating a new one
Currently, all user dialogues are kept and stored in MongoDB, even when a user begins a new dialogue or restarts the bot, which can become quite packed with useless data overtime as the user will not need these old dialogues at this stage of the project, especially if thousands of users use the bot. I also think it's much better from a user's privacy standpoint.
With the changes below, old dialogues will be deleted from the database whether:
- User creates a new dialogue with /new
- User stops and restarts the bot
- Dialogue restarts due to timeout
- User switches to another chat mode
I believe in the future we could look into keeping at least 5 dialogues and having a chat history option and possibility to switch to old contexts as on ChatGPT web.
Tried this on a test bot and it worked great. See if you find this useful not.