mercm8 / chat-llama-discord-bot

A Discord Bot for chatting with LLaMA, Vicuna, Alpaca, or any other LLM supported by text-generation-webui or llama.cpp.
https://discord.gg/TcRGDV754Y
MIT License
16 stars 4 forks source link

Bot replies to itself when it says its own name #3

Closed Garry-Marshall closed 1 year ago

Garry-Marshall commented 1 year ago

Probably in this part of the code:

    if (self.only_speak_when_spoken_to and client.user.mentioned_in(message) \
               or any(word in message.content.lower() for word in client.user.display_name.lower().split())) \
           or (self.in_active_conversation(message.author.id) and message.channel.id == self.main_channel):
       """ If bot is set to only speak when spoken to and someone uses its name
           or if is in an active conversation with the user in the main channel, we reply. 
           This is a messy one. """
Garry-Marshall commented 1 year ago

I tried adding

and message.author != client.user:

but that doesn't change anything.

From time to time, it gets stuck in a loop and repeats itself over and over again. Setting the self.chance_to_reply_to_other_bots to 0 seems to mitigate it. At least couldn't reproduce it again after that change. edit: issue still persists. Bot keeps repeating itself. Asking 'What is your name' triggers it pretty consistently.

mercm8 commented 1 year ago

Ah, I havent noticed this, thanks for pointing it out. Guess I have to stir the spaghetti some more.. Pretty sure there already is a "do not reply to yourself" logic in the behavior that should make it abort immediately, but it's probably overridden by some other spaghetti at this point. Maybe the bit that lets it reply to other users who are also bots.

Garry-Marshall commented 1 year ago

Maybe the bit that lets it reply to other users who are also bots.

Yeah, that's the part controlled with the probability? I set it to 0 to exclude that, but that didn't change a thing.

Well, I noticed that if I set the bot's nickname to something else than its used name, the loop doesn't occur when it writes it's own name. (it triggers only once, and produces two lines of output instead of an infinite loop)

User: What is your name BOT My name is Bot BOT My name is Bot BOT My name is Bot ...

After changing the nickname:

User: What is your name Nickname My name is Bot Nickname You know who I am

Haven't had it stuck in a loop again after that. Not sure how relevant it is, but maybe this can pinpoint you to the root of the issue.

mercm8 commented 1 year ago

This is a weird one, and doesnt happen on my build right now. I hastily pushed some other fix after they updated oobabooga though, so I may have missed something then. I did notice some similar weird repeating errors then too.

I've updated it now, with a bit of a brute force to stop it from replying to itself at least, hoping it'll work out. Gonna let it run for a while and see if it repeats itself.

Garry-Marshall commented 1 year ago

That seems to have fixed it.