Skip to content
This repository was archived by the owner on May 18, 2024. It is now read-only.

AttributeError: module 'asyncio' has no attribute 'to_thread' #234

Closed
Dron007 opened this issue Oct 4, 2023 · 1 comment
Closed

AttributeError: module 'asyncio' has no attribute 'to_thread' #234

Dron007 opened this issue Oct 4, 2023 · 1 comment

Comments

@Dron007
Copy link

Dron007 commented Oct 4, 2023

I installed the bot, added persona. When I refer to it, it adds reaction and starts typing but there is no any text.
In console I see this error:

[2023-10-04 19:54:23] [ERROR   ] discord.client: Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Python\lib\site-packages\discord\client.py", line 441, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 173, in on_message
    response = await asyncio.to_thread(generate_response, instructions=instructions, search=search_results, history=history)
AttributeError: module 'asyncio' has no attribute 'to_thread'

Also right after starting I see this:

C:\Projects\AI\Discord-AI-Chatbot>python main.py                                                                                                                              Looks like the environment variables exists...
Discord Token environment variable is valid
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000206B9C5D4C0>
Traceback (most recent call last):
  File "C:\Python\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Python\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Python\lib\asyncio\base_events.py", line 719, in call_soon
    self._check_closed()
  File "C:\Python\lib\asyncio\base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Not sure whether it is normal or not.

@Dron007
Copy link
Author

Dron007 commented Oct 5, 2023

The problem was in Python 3.8. But when I upgraded it to 3.12 it didn't work because of aiohttp library . So I downgraded it to Python 3.11.
Other issues is with naga key which couldn't be retrieved now. I used OPEN_AI key and commented out https://github.com/mishalhossin/Discord-AI-Chatbot/blob/main/bot_utilities/ai_utils.py#L20

It would be nice to have an option to use OpenAI key.

@mishl-dev mishl-dev closed this as not planned Won't fix, can't repro, duplicate, stale Oct 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants