MP2I-Kleber / another-mp2i-bot

Le meilleur bot Discord qu'une promo de CPGE puisse avoir :)
MIT License
18 stars 12 forks source link

Fix openAI #34

Closed AiroPi closed 5 months ago

AiroPi commented 7 months ago
another-mp2i-bot-mp2i-bot-1  | 2023-11-22 23:41:25 ERROR    discord.client Ignoring exception in on_message
another-mp2i-bot-mp2i-bot-1  | Traceback (most recent call last):
another-mp2i-bot-mp2i-bot-1  |   File "/usr/local/lib/python3.12/site-packages/discord/client.py", line 441, in _run_event
another-mp2i-bot-mp2i-bot-1  |     await coro(*args, **kwargs)
another-mp2i-bot-mp2i-bot-1  |   File "/app/cogs/openai_chatbot.py", line 183, in on_message
another-mp2i-bot-mp2i-bot-1  |     await self.ask_to_openIA(message)
another-mp2i-bot-mp2i-bot-1  |   File "/app/cogs/openai_chatbot.py", line 167, in ask_to_openIA
another-mp2i-bot-mp2i-bot-1  |     response = await self.send_chat_completion(messages, message.channel, user=username)
another-mp2i-bot-mp2i-bot-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
another-mp2i-bot-mp2i-bot-1  |   File "/app/cogs/openai_chatbot.py", line 92, in send_chat_completion
another-mp2i-bot-mp2i-bot-1  |     response = await openai.ChatCompletion.acreate(**kwargs)  # type: ignore
another-mp2i-bot-mp2i-bot-1  |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
another-mp2i-bot-mp2i-bot-1  |   File "/usr/local/lib/python3.12/site-packages/openai/_utils/_proxy.py", line 22, in __getattr__
another-mp2i-bot-mp2i-bot-1  |     return getattr(self.__get_proxied__(), attr)
another-mp2i-bot-mp2i-bot-1  |                    ^^^^^^^^^^^^^^^^^^^^^^
another-mp2i-bot-mp2i-bot-1  |   File "/usr/local/lib/python3.12/site-packages/openai/_utils/_proxy.py", line 43, in __get_proxied__
another-mp2i-bot-mp2i-bot-1  |     return self.__load__()
another-mp2i-bot-mp2i-bot-1  |            ^^^^^^^^^^^^^^^
another-mp2i-bot-mp2i-bot-1  |   File "/usr/local/lib/python3.12/site-packages/openai/lib/_old_api.py", line 33, in __load__
another-mp2i-bot-mp2i-bot-1  |     raise APIRemovedInV1(symbol=self._symbol)
another-mp2i-bot-mp2i-bot-1  | openai.lib._old_api.APIRemovedInV1: 
another-mp2i-bot-mp2i-bot-1  | 
another-mp2i-bot-mp2i-bot-1  | You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.
another-mp2i-bot-mp2i-bot-1  | 
another-mp2i-bot-mp2i-bot-1  | You can run `openai migrate` to automatically upgrade your codebase to use the 1.0.0 interface. 
another-mp2i-bot-mp2i-bot-1  | 
another-mp2i-bot-mp2i-bot-1  | Alternatively, you can pin your installation to the old version, e.g. `pip install openai==0.28`
another-mp2i-bot-mp2i-bot-1  | 
another-mp2i-bot-mp2i-bot-1  | A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742
chloepilonv commented 7 months ago

The library got updated. For example, instead of openai.ChatCompletion.create(), you may want to use openai.chat.completion.create(). The library's updates are here :https://github.com/openai/openai-python