n3d1117 / chatgpt-telegram-bot

πŸ€– A Telegram bot that integrates with OpenAI's official ChatGPT APIs to provide answers, written in Python
GNU General Public License v2.0
3.06k stars 1.41k forks source link

Issue with Conversation Separation in Group Chats #209

Open sobhansajjadi opened 1 year ago

sobhansajjadi commented 1 year ago

Dear n3d1117 πŸ˜…

I hope this message finds you well. I am a beginner in coding and have been using your GitHub code for a Telegram bot connected to OpenAI. I have encountered a few issues and have some feature requests that I hope you can address. I apologize for any inconvenience and appreciate your help.

The bot does not seem to separate user information in group chats. It mixes the conversation history of users, combining different topics into a single conversation. This makes it difficult to follow specific discussions.

There is an environment variable called "max_history_size" that determines the length of each conversation. However, when this variable is set to 1, the bot still continues the conversation if a user replies to a message. It seems to ignore the specified value.

It would be beneficial to have an environment variable that can disable the bot's response to reply messages.

Could you please add a variable to control which users have permission to create images and set usage limits within a specific time frame?

Thank you for generously sharing your code for free. Your contribution to the community is truly appreciated.

πŸ’•πŸ’•this message was written with the assistance of GPT-4, as my native language is not English. πŸ’•πŸ’•

I hope my explanations were concise and clear. I look forward to any improvements or updates you can make to address these issues.

Best regards,

n3d1117 commented 1 year ago

Hi @sobhansajjadi and thanks for your kind words!

The bot does not seem to separate user information in group chats. It mixes the conversation history of users, combining different topics into a single conversation. This makes it difficult to follow specific discussions.

Yes, right now the bot treats a group chat as a single conversation. If I understand your request, you want every user of a group chat to have a unique conversation instead?

There is an environment variable called "max_history_size" that determines the length of each conversation. However, when this variable is set to 1, the bot still continues the conversation if a user replies to a message. It seems to ignore the specified value.

MAX_HISTORY_SIZE is used to control how many messages should be kept in the conversation before summarizing it. It doesn't control whether to reset the conversation or not. If you wish to reset the conversation more often, you could use MAX_CONVERSATION_AGE_MINUTES instead and set it to a very low value (e.g. 0.1 which means a conversation lasts ~6 seconds)

It would be beneficial to have an environment variable that can disable the bot's response to reply messages.

In group chats you mean? You'd like the bot to only answer to mentions but not replies? Could you elaborate on the use case for this?

Could you please add a variable to control which users have permission to create images

This could be a part of presets, currently open at https://github.com/n3d1117/chatgpt-telegram-bot/pull/183, maybe you could add your request there

and set usage limits within a specific time frame?

That would be cool, maybe you could request this under the Budget Manual so it can be discussed? https://github.com/n3d1117/chatgpt-telegram-bot/discussions/184

sobhansajjadi commented 1 year ago

Yes, right now the bot treats a group chat as a single conversation. If I understand your request, you want every user of a group chat to have a unique conversation instead?

Yes, in group chats, each person has a different conversation and talks to the bot about a specific topic. If we combine all of these into a single conversation, they won't receive appropriate responses, and the topics will mix together.

you could use MAX_CONVERSATION_AGE_MINUTES instead and set it to a very low value (e.g. 0.1 which means a conversation lasts ~6 seconds)

Thank you, I will need to test that. It might potentially solve one of my main issues.

In group chats you mean? You'd like the bot to only answer to mentions but not replies? Could you elaborate on the use case for this?

Yes, in group chats. For example, a user asks the bot to tell a joke, and the bot sends a response. Then, 50 other users reply to the bot's response with their opinions, which don't require a response from the bot. However, the bot generates a response for all the emojis.

If you could kindly guide me on how to solve these issues, I might be able to fix them with the help of GPT.

Finally, thank you for your prompt response.🀍

BogartDevilCode commented 1 year ago

Hello! I'm also new to programming and I've encountered the following problem: when multiple people use the bot, there is a queue in the response, meaning that the GPT-3 model does not respond to a user until it has responded to another user. My question is, is it possible to implement multi-threading on a free token so that the bot can respond to each user regardless of who was first?