sazonovanton/SirChatalot

Add max conversation feature

Closed this issue · 2 comments

Afrezi commented

Adding a maximum conversation feature, for example when the user reaches 5 messages sent to the Telegram bot, it will automatically trigger the /delete command. This feature is very useful because it can save the use of Openai api tokens.

I would suggest doing automatic deletion if the chat has not been written for more than 10 minutes.
Then there should be no problem with the context, because the user can refer to the context at any moment of communication and it is important that the bot understands this context. And if the user does not use the chat for more than 10 minutes - most likely the topic is no longer relevant and you can clear the context.

Or do by analogy with Bing:
Display in each message the number of requests before the context is reset, for example, "2/5".
Those. after the 5th request, the context will be deleted.

I don't want to delete user data without explicit command from user himself, so I will not implement auto-deletion.

I have added commented parts of code for deleteing user session after limit is reached. Right now bot summarizes previous conversation and continues, but you can make it delete conversation.
There are currently two parts where you should uncomment code. I should have created function for that so code won't be reused, but I'll refactor code later.

Instruction:
https://imgur.com/a/SOID0H6