Zero6992 / chatGPT-discord-bot

Integrate ChatGPT into your own discord bot
GNU General Public License v2.0
2.67k stars 704 forks source link

asyncio.run() cannot be called from a running event loop #63

Closed RustyReich closed 1 year ago

RustyReich commented 1 year ago

After the bot runs for awhile, I start getting this error and the bot is not able to send messages.

2022-12-14 16:58:34 ERROR    src.bot -> Error while sending message: asyncio.run() cannot be called from a running event loop
Traceback (most recent call last):
  File "/home/ubuntu/chatGPT-discord-bot/src/bot.py", line 18, in send_message
    response += await responses.handle_response(user_message)
  File "/home/ubuntu/chatGPT-discord-bot/src/responses.py", line 6, in handle_response
    chatbot.refresh_session()
  File "/home/ubuntu/.local/lib/python3.10/site-packages/revChatGPT/revChatGPT.py", line 311, in refresh_session
    asyncio.run(self.get_cf_cookies())
  File "/usr/lib/python3.10/asyncio/runners.py", line 33, in run
    raise RuntimeError(
RuntimeError: asyncio.run() cannot be called from a running event loop
/home/ubuntu/chatGPT-discord-bot/src/bot.py:57: RuntimeWarning: coroutine 'AsyncChatbot.get_cf_cookies' was never awaited
  logger.exception(f"Error while sending message: {e}")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Zero6992 commented 1 year ago

What version of revChatGPT are you running?

RustyReich commented 1 year ago

Was using 0.0.43. Just updated to 0.0.44. Will report back if the issue seems to be fixed with the update or not.

Zero6992 commented 1 year ago

Change to Using OpenAI official GPT-3 API now