WAppAI / assistant

A WhatsApp chatbot that leverages Bing AI's and others LLMs conversational capabilities.
MIT License
93 stars 31 forks source link

Request is throttled #69

Closed sudoalx closed 1 year ago

sudoalx commented 1 year ago

I'm getting this error no matter how much I tried to fix it. It worked for about an hour then never again.

DM message received from XXXX[XXXXXXXXXXXXX]
{
  error: {
    name: 'Error',
    message: 'Throttled: Request is throttled.',
    stack: 'Error: Throttled: Request is throttled.\n' +
      '    at WebSocket.<anonymous> (file:///home/alex/sydney-whatsapp-chatbot/node_modules/@waylaidwanderer/chatgpt-api/src/BingAIClient.js:493:36)\n' +
      '    at WebSocket.emit (node:events:525:35)\n' +
      '    at WebSocket.emit (node:domain:489:12)\n' +
      '    at Receiver.receiverOnMessage (/home/alex/sydney-whatsapp-chatbot/node_modules/ws/lib/websocket.js:1184:20)\n' +
      '    at Receiver.emit (node:events:513:28)\n' +
      '    at Receiver.emit (node:domain:489:12)\n' +
      '    at Receiver.dataMessage (/home/alex/sydney-whatsapp-chatbot/node_modules/ws/lib/receiver.js:541:14)\n' +
      '    at Receiver.getData (/home/alex/sydney-whatsapp-chatbot/node_modules/ws/lib/receiver.js:459:17)\n' +
      '    at Receiver.startLoop (/home/alex/sydney-whatsapp-chatbot/node_modules/ws/lib/receiver.js:158:22)\n' +
      '    at Receiver._write (/home/alex/sydney-whatsapp-chatbot/node_modules/ws/lib/receiver.js:84:10)\n' +
      '    at writeOrBuffer (node:internal/streams/writable:392:12)\n' +
      '    at _write (node:internal/streams/writable:333:10)\n' +
      '    at Receiver.Writable.write (node:internal/streams/writable:337:10)\n' +
      '    at TLSSocket.socketOnData (/home/alex/sydney-whatsapp-chatbot/node_modules/ws/lib/websocket.js:1278:35)\n' +
      '    at TLSSocket.emit (node:events:513:28)\n' +
      '    at TLSSocket.emit (node:domain:489:12)'
  }
}
Luisotee commented 1 year ago

BingAPI has a limit of 200 messages every 24h. Current fix is to either wait 24h or change to another API key. You can read more about this here.

sudoalx commented 1 year ago

BingAPI has a limit of 200 messages every 24h. Current fix is to either wait 24h or change to another API key. You can read more about this here.

I haven't reached that limit yet tho and I'm still able to use it through the normal Bing chat interface. Could it be something else? I'm hosting this bot from a VPS with public IP address

veigamann commented 1 year ago

It's possible that Bing is indeed being throttled due to running on a VPS. I have had a similar issue myself. You can try running behind a proxy. Please attempt running it on a local machine and test if you still receive this error.

dinushay commented 1 year ago

BingAPI has a limit of 200 messages every 24h. Current fix is to either wait 24h or change to another API key.

It has been changed to 300 per 24 hours

veigamann commented 1 year ago

Any updates, @sudoalx?

sudoalx commented 1 year ago

Any updates, @sudoalx?

Hey sorry for the late reply. I can confirm last time I ran out of requests and that's why the error happened.

On the other hand, I've tried cookies from different accounts and only the "normal accounts" (@hotmail.com @outlook.com ...) seem to work from a VPS.

I also have a developer E5 account but that immediately throws this error:

Error:

/turing/conversation/create: Your IP is blocked by BingAI.

So for now I'm only using my normal accounts on my VPS and the developer E5 account on my local machine.

I've thought of the possibility of auto rotating the cookies when BingAI runs out of requests kind of like how tools like gclone (fork from rclone) do with Google Service Accounts. But I think that's a topic for another issue? Anyway, I'll attempt to do it and let you know if I succeed by any chance.

veigamann commented 1 year ago

I have two Microsoft student accounts, and they don't work either. It only seems to work with regular accounts. In fact, I lost permanent access to Bing Chat on one of my regular accounts because I used the bot in a group chat.

Also, I did try to run the bot on a VPS but I encountered turing errors too. It only worked when I hosted it locally on my machine. I would suggest trying to run the bot without using any cookies at all, as they are no longer necessary. However, I have noticed that running it without cookies is more prone to errors.

The idea of rotating cookies is interesting. I've thought about it before, but personally, I don't know how to implement it, although I'm eager to learn. If you have the time and interest to implement it, feel free to open another issue so that we can discuss possible implementation methods and work together on it. This is my first major public repository/project on GitHub, so I'm still learning how to manage software and collaborate with others. Any feedback you have would be greatly appreciated.

If you have any insights or suggestions regarding this issue or any other aspect of the project, I'd be more than happy to hear them! I'm open to ideas and always looking to improve.

sudoalx commented 1 year ago

Oh, I got the same "IP restricted" error with my student account too. It seems to be an issue with organizational accounts maybe MS 365 accounts, well for me, it at least worked from my local machine in my home network which is residential.

I haven't tried running the bot without cookies yet, but I'll definitely give it a shot if I run out of requests and cookies 🍪

Speaking of cookies... I've been thinking about the implementation of the cookie rotation feature, but I haven't made any progress yet LoL. Once I have a potential solution, I'll fork the repository, make the necessary changes, and submit a pull request for your review. I'm also kinda new to the process of contributing on GitHub, but this is how they usually do it, so I guess that's the "right way".

I've also been thinking of some ideas related to error handling, and I'm considering creating different branches to explore them. I'll keep you updated as I make progress :)

I'll be happy to contribute to this project 🎉

solution01 commented 1 year ago

It would not be possible to put a response counter so we don't pass the easy limit...

Luisotee commented 1 year ago

It would not be possible to put a response counter so we don't pass the easy limit...

Vou tentar fazer isso pra semana que vem.

Luisotee commented 1 year ago

It would not be possible to put a response counter so we don't pass the easy limit...

Implemented in #94