发生异常: AttributeError
module 'openai' has no attribute 'error'
File "D:\Mirai_Kaguya\OpenAI_Chat3.5-python-server\AI.py", line 157, in speak
resp = chat_completion_timeout(select_model, self.messages, self.temperature)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Mirai_Kaguya\OpenAI_Chat3.5-python-server\AI.py", line 34, in chat_completion_timeout
return openai.ChatCompletion.create(model=model, messages=messages, temperature=temperature)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
openai.lib._old_api.APIRemovedInV1:
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.
You can run openai migrate
to automatically upgrade your codebase to use the 1.0.0 interface.
Alternatively, you can pin your installation to the old version, e.g. pip install openai==0.28
A detailed migration guide is available here: https://github.com/openai/openai-python/discussions/742
During handling of the above exception, another exception occurred:
File "D:\Mirai_Kaguya\OpenAI_Chat3.5-python-server\AI.py", line 158, in speak
except openai.error.RateLimitError as e: # 需要单独判断是否触发api速度限制
^^^^^^^^^^^^
File "D:\Mirai_Kaguya\OpenAI_Chat3.5-python-server\AI.py", line 181, in chat
message = self.speak()
^^^^^^^^^^^^
File "D:\Mirai_Kaguya\OpenAI_Chat3.5-python-server\net.py", line 112, in type_chat
send_string(server, system.AI_list[index].chat(question)) # 需判断error
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Mirai_Kaguya\OpenAI_Chat3.5-python-server\net.py", line 259, in protocol
type_chat(server, index)
AttributeError: module 'openai' has no attribute 'error'