报错信息
raise error.APIConnectionError(
openai.error.APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host=’api.openai.com’, port=443): Max retries exceeded with url: /v1/chat/completions (Caused by ProxyError(‘Cannot connect to proxy.’, NewConnectionError(‘: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。’)))
主要原因为代理的问题,需要魔法
解决方法
需要修改的文件为
…\你的环境\site-packages\openai\api_requestor.py
设置代理
proxy = {'http': "http://127.0.0.1:7890",
'https': "http://127.0.0.1:7890"}