johnnymcmike / Gravital

A Discord AI Chatbot that uses GPT-2 and aitextgen for fast, believable responses that you can train on your own discord server's message history
MIT License
34 stars 5 forks source link

[Enhancement/Feature Req?] A request to implement a feature or know if possible to do #1

Open ascii2048 opened 3 years ago

ascii2048 commented 3 years ago

Thanks for reading! I was wondering if it were possible to have the bot show that it is typing once it registers that it will respond to someone's message, then type for the duration till the message is sent?

Also thanks for taking the time to share this repo. Finding something updated or with easy to read/follow steps and code for a bot like this has been a struggle

johnnymcmike commented 3 years ago

Hey, thanks for the request! I understand your struggle, that's why I decided to make this repo public in the first place. Just added in the feature, was an easier fix than I thought. If anyone's curious, I just changed with message.channel.typing to async with message.channel.typing and moved it further up the code for responsiveness' sake.

The first message the bot receives after you turn it on will always be handled sort of sluggishly for reasons I'm not really sure of. So don't worry if the typing indicator acts weird or doesn't display at all for that first message, because in my testing (and running on that same ancient i5) it's perfectly snappy on all subsequent messages. Enjoy!

ascii2048 commented 3 years ago

Thanks for adding this btw! I really don't know if this is the appropriate place to add on, but I had a question about the feature. When I execute and the bot shows as "typing" it usually end the typing event a few seconds to a minute before the bot sends its actual message. Is this intentional just by nature of the program or is that an issue on my end?

Also if we wanted the bot to only respond in specific servers do you know which file this code should be added, if it's something possible?

johnnymcmike commented 3 years ago

Hmmm. Reopening issue for now, others please comment if you're experiencing the same.

I haven't experienced this at all. The bot in general shouldn't be taking longer than 10 or so seconds to get a response. What GPT model did you train? The testing I did for the typing feature was done on 124M and 355M. 355M is a tad slower but never takes longer than 20 seconds, in my experience. If you're using something larger than 355M then I'd recommend you just use 355M, as the higher you go, things start to get crazy heavy and the returns that you get (especially for relatively small things like generating one line of conversational text) kind of diminish.

Another concern might be RAM. My bot may run off an ancient i5, but that server has 8GB of ram, and almost all of it is available as nothing else was running at the time. Running this locally off of your own daily-driver computer while other things are happening in the background is perfectly doable, but not really recommended as it sucks up CPU and RAM from your other programs as well as not really being suitable for leaving unattended. (My friends in different time zones want to play with it too, after all!) I've noticed this when trying to run it on my laptop, whose Ryzen 5 3550H is hypothetically superior to my server's i5-2400 with the same amount of memory. Things generally take way longer and act buggier even on 124M. If you have a VPS or old desktop computer or Raspberry Pi or anything else you can use as a headless server, try running Gravital off of that and see if the issue persists. If your connection is bad then that could be causing it, too, since what you're describing sounds kind of like what would happen to a laggy human sending a normal message in a discord channel.

As far as customizing where auto-response can happen, I recognize that that's an issue (you might want it to be @-able in #general, for example, without having it interrupt your conversations randomly.) I've been trying to think of ways to implement that, and whenever it's done I'll comment here and release it as v1.3. It'll probably be handled in bot.py and managed on a per-channel basis, so you can do what you like with that as far as allowing / disallowing entire servers.