GaiZhenbiao / ChuanhuChatGPT

GUI for ChatGPT API and many LLMs. Supports agents, file-based QA, GPT finetuning and query with web search. All with a neat UI.

Home Page:https://huggingface.co/spaces/JohnSmith9982/ChuanhuChatGPT

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

已解决:报错openai.error.APIConnectionError

Kuzoa opened this issue · comments

commented

返回错误信息:
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 SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)')))

我试过更换API KEY、使用全局代理都显示这个错误。

Chatgpt说:该代码中使用了Python的raise语句来抛出APIConnectionError异常,这是一个自定义的异常类,表示与OpenAI API通讯时发生了错误。其中的错误信息包括了请求的URL地址以及导致错误的具体原因。从错误信息中可以看出,这个异常是由OpenAI API返回的,表明与该API的通讯过程中出现了SSLError(SSL错误)的异常,而具体的错误原因是违反了SSL协议。因此,这是一个由于与OpenAI API通讯时出现SSL连接问题而导致的异常。

commented

只更改过API KEY没动过其他

被墙了,挂代理

检查一下代理设置

commented

检查一下代理设置

我换了好几个不同节点都不行。但是vscode的chatgpt插件倒是可以正常使用。
所以我觉得问题不是出在代理上

commented

如果有人出现了和我同样的问题,解决方案是卸载urllib3然后重装至1.25.11版本再重新运行一遍就可以。

在终端或命令提示符中卸载urllib3
pip uninstall urllib3

然后,您可以通过使用指定版本号的pip install命令来安装所需的版本:
pip install urllib3==1.25.11

参考自:知乎:解决OpenAI API 挂了代理还是连接不上的问题 openai.error.APIConnectionError

重装了urlib3,又报另外一个错误:

openai.error.RateLimitError: Your access was terminated due to violation of our policies, please check your email for more information. If you believe this is in error and would like to appeal, please contact support@openai.com.

commented

重装了urlib3,又报另外一个错误:

openai.error.RateLimitError: Your access was terminated due to violation of our policies, please check your email for more information. If you believe this is in error and would like to appeal, please contact support@openai.com.

这个链接你参考一下:openAI|如何处理费率限制

重装了urlib3,换了几个不同的代理还是不行呜呜呜

重装了urlib3,换了几个不同的代理还是不行呜呜呜

我朝,我也刚开始试,我换全局代理也不行,不会是要寄了吧

重装了urlib3,换了几个不同的代理还是不行呜呜呜

我又重新安装了一遍,现在可以了,你用https://whoer.net/zh测试一下你现在的ip

呜呜我还是不行

image
更新了版本还是这个问题

image更新了版本还是这个问题

请问您成功解决了吗

厉害,真的解决了,确实是先卸载urllib3,然后再重新安装,不知道是什么原理,难道是因为证书没有更新的原因吗

commented

我换1.25.11提示要高于1.26.00版本啊 搞死我了

commented

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
selenium 4.8.3 requires urllib3[socks]~=1.26, but you have urllib3 1.25.11 which is incompatible.
docker 6.0.1 requires urllib3>=1.26.0, but you have urllib3 1.25.11 which is incompatible.

已验证,忽略要求版本1.26.00的提示,直接uninstall 然后安装urllib3 2.25.11即可以正常运行。

Successfully uninstalled urllib3-1.26.15
Successfully installed urllib3-1.25.11
我重装了也不行,我面临的问题是正常使用一直都没问题,但async调用就会一直APIConnectionError

commented

mac下面正常,UB下面出现ssl 问题,启动正常,代理也正常,其他程序访问openai正常, 就是这个有问题,降级了urllib到1.25 也操作过了。

2023-05-08 18:59:54,302 [INFO] [utils.py:407] Your IP region: Australia。
2023-05-08 18:59:54,362 [INFO] [ChuanhuChatbot.py:461]
川虎的温馨提示:访问 http://localhost:7860 查看界面
Reloading javascript...
Running on local URL: http://0.0.0.0:39644

To create a public link, set share=True in launch().
2023-05-08 19:00:21,615 [INFO] [models.py:562] 正在加载OpenAI模型: gpt-3.5-turbo
2023-05-08 19:00:21,615 [INFO] [models.py:604] Model is set to: gpt-3.5-turbo
2023-05-08 19:00:21,880 [INFO] [models.py:562] 正在加载OpenAI模型: gpt-3.5-turbo
2023-05-08 19:00:21,880 [INFO] [models.py:604] Model is set to: gpt-3.5-turbo
2023-05-08 19:00:24,646 [INFO] [base_model.py:283] 输入为:
2023-05-08 19:00:24,655 [INFO] [base_model.py:312] ☹️Error: Enter the content of the conversation.
2023-05-08 19:00:27,560 [ERROR] [models.py:91] 获取API使用情况失败:SOCKSHTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /dashboard/billing/usage?start_date=2023-05-01&end_date=2023-05-31 (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1007)')))

commented

mac下面正常,UB下面出现ssl 问题,启动正常,代理也正常,其他程序访问openai正常, 就是这个有问题,降级了urllib到1.25 也操作过了。

2023-05-08 18:59:54,302 [INFO] [utils.py:407] Your IP region: Australia。 2023-05-08 18:59:54,362 [INFO] [ChuanhuChatbot.py:461] 川虎的温馨提示:访问 http://localhost:7860 查看界面 Reloading javascript... Running on local URL: http://0.0.0.0:39644

To create a public link, set share=True in launch(). 2023-05-08 19:00:21,615 [INFO] [models.py:562] 正在加载OpenAI模型: gpt-3.5-turbo 2023-05-08 19:00:21,615 [INFO] [models.py:604] Model is set to: gpt-3.5-turbo 2023-05-08 19:00:21,880 [INFO] [models.py:562] 正在加载OpenAI模型: gpt-3.5-turbo 2023-05-08 19:00:21,880 [INFO] [models.py:604] Model is set to: gpt-3.5-turbo 2023-05-08 19:00:24,646 [INFO] [base_model.py:283] 输入为: 2023-05-08 19:00:24,655 [INFO] [base_model.py:312] ☹️Error: Enter the content of the conversation. 2023-05-08 19:00:27,560 [ERROR] [models.py:91] 获取API使用情况失败:SOCKSHTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /dashboard/billing/usage?start_date=2023-05-01&end_date=2023-05-31 (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1007)')))

socks代理写错了 原:
// 如果使用代理,请取消注释下面的两行,并替换代理URL "https_proxy": "socks5://127.0.0.1:7890", "http_proxy": "socks5://127.0.0.1:7890",

改成:
// 如果使用代理,请取消注释下面的两行,并替换代理URL "https_proxy": "socks5h://127.0.0.1:7890", "http_proxy": "socks5h://127.0.0.1:7890",

OK了

Successfully uninstalled urllib3-1.26.15 Successfully installed urllib3-1.25.11 我重装了也不行,我面临的问题是正常使用一直都没问题,但async调用就会一直APIConnectionError

你好,我遇到了与你一样的问题,用acreate就不行,请问你解决了吗?

Successfully uninstalled urllib3-1.26.15 Successfully installed urllib3-1.25.11 我重装了也不行,我面临的问题是正常使用一直都没问题,但async调用就会一直APIConnectionError

我也是这个问题,兄弟你解决了吗?

commented

@ALL 香港某些vpn服务器ip被openai封了,用日本的

commented

太牛了,解决了,谢谢大佬

docker启动的怎么解决呢

我这边遇到类似情况,代理IP挂掉了,我换成新加坡节点就可以了。

我用的 clash,开启 TUN 模式之后解决问题,上面所有情况都没有解决我的问题。

我用的 clash,开启 TUN 模式之后解决问题,上面所有情况都没有解决我的问题。

我遇到的情况和你一样,开启TUN之后解决了async调用的问题

用的clash开了tun和全局模式,还是报了错误:APIConnectionError: Connection error.

用的clash开了tun和全局模式,还是报了错误:APIConnectionError: Connection error.

请给出详细的错误日志

用的clash开了tun和全局模式,还是报了错误:APIConnectionError: Connection error.

同样,报一样的错误

我pip install urllib3==1.25.11还是解决不了,由于用的clash统一port都是7890,最后在主文件中配置环境解决了问题
import os

os.environ["http_proxy"] = "http://localhost:7890"
os.environ["https_proxy"] = "http://localhost:7890"

请问clash不开全局代理就直接用不了是吗?

我pip install urllib3==1.25.11还是解决不了,由于用的clash统一port都是7890,最后在主文件中配置环境解决了问题 import os

os.environ["http_proxy"] = "http://localhost:7890" os.environ["https_proxy"] = "http://localhost:7890"

已解决

我想跑一下openai给的示例:
import os
from openai import OpenAI

  client = OpenAI(
      # This is the default and can be omitted
      api_key=os.environ.get("OPENAI_API_KEY"),
  )
  
  chat_completion = client.chat.completions.create(
      messages=[
          {
              "role": "user",
              "content": "Say this is a test",
          }
      ],
      model="gpt-3.5-turbo",
  )

在colab上面就能跑通,我得vpn是没问题的,为何到pycharm上就报错openai.APIConnectionError: Connection error.
pycharm我用的SSH连接服务器在跑
求哪位大神指点一下?

我想跑一下openai给的示例: import os from openai import OpenAI

  client = OpenAI(
      # This is the default and can be omitted
      api_key=os.environ.get("OPENAI_API_KEY"),
  )
  
  chat_completion = client.chat.completions.create(
      messages=[
          {
              "role": "user",
              "content": "Say this is a test",
          }
      ],
      model="gpt-3.5-turbo",
  )

在colab上面就能跑通,我得vpn是没问题的,为何到pycharm上就报错openai.APIConnectionError: Connection error. pycharm我用的SSH连接服务器在跑 求哪位大神指点一下?

在config里设定一下代理的地址吧

我想跑一下openai给的示例: import os from openai import OpenAI

  client = OpenAI(
      # This is the default and can be omitted
      api_key=os.environ.get("OPENAI_API_KEY"),
  )
  
  chat_completion = client.chat.completions.create(
      messages=[
          {
              "role": "user",
              "content": "Say this is a test",
          }
      ],
      model="gpt-3.5-turbo",
  )

在colab上面就能跑通,我得vpn是没问题的,为何到pycharm上就报错openai.APIConnectionError: Connection error. pycharm我用的SSH连接服务器在跑 求哪位大神指点一下?

在config里设定一下代理的地址吧

请问怎么设定呢?是通过nano ~/.ssh/config文件里面写入嘛,原谅我刚开始用api,不太熟

我想跑一下openai给的示例: import os from openai import OpenAI

  client = OpenAI(
      # This is the default and can be omitted
      api_key=os.environ.get("OPENAI_API_KEY"),
  )
  
  chat_completion = client.chat.completions.create(
      messages=[
          {
              "role": "user",
              "content": "Say this is a test",
          }
      ],
      model="gpt-3.5-turbo",
  )

在colab上面就能跑通,我得vpn是没问题的,为何到pycharm上就报错openai.APIConnectionError: Connection error. pycharm我用的SSH连接服务器在跑 求哪位大神指点一下?

在config里设定一下代理的地址吧

请问怎么设定呢?是通过nano ~/.ssh/config文件里面写入嘛,原谅我刚开始用api,不太熟

在川虎Chat的config.json配置文件里

也有可能是梯子的问题 多换几个节点试试 我就是试了好多办法,最后换了个节点成功了,太离谱了

commented

我的梯子显示终端代理信息为:export https_proxy=http://127.0.0.1:33210 http_proxy=http://127.0.0.1:33210 all_proxy=socks5://127.0.0.1:33211
结果加上
import os
os.environ["http_proxy"] = "http://127.0.0.1:33210"
os.environ["https_proxy"] = "http://127.0.0.1:33210"
就好了


UnsupportedProtocol Traceback (most recent call last)
File ~/.local/lib/python3.10/site-packages/httpx/_transports/default.py:69, in map_httpcore_exceptions()
68 try:
---> 69 yield
70 except Exception as exc:

File ~/.local/lib/python3.10/site-packages/httpx/_transports/default.py:233, in HTTPTransport.handle_request(self, request)
232 with map_httpcore_exceptions():
--> 233 resp = self._pool.handle_request(req)
235 assert isinstance(resp.stream, typing.Iterable)

File ~/.local/lib/python3.10/site-packages/httpcore/_sync/connection_pool.py:167, in ConnectionPool.handle_request(self, request)
166 if scheme == "":
--> 167 raise UnsupportedProtocol(
168 "Request URL is missing an 'http://' or 'https://' protocol."
169 )
170 if scheme not in ("http", "https", "ws", "wss"):

UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

The above exception was the direct cause of the following exception:

UnsupportedProtocol Traceback (most recent call last)
File ~/.python/current/lib/python3.10/site-packages/openai/_base_client.py:926, in SyncAPIClient._request(self, cast_to, options, remaining_retries, stream, stream_cls)
...
963 'HTTP Request: %s %s "%i %s"', request.method, request.url, response.status_code, response.reason_phrase
964 )
966 try:

APIConnectionError: Connection error.

求助大神们,这种问题该怎么解决,貌似是协议问题

Screenshot 2024-04-01 at 5 11 57 PM proxies已经在代码特别注明了,规则我也写了, 在curl连接和各种vpn检查都做了,vpn是没问题的,但只要一调用api,就会出现connection error,还有什么办法吗? Screenshot 2024-04-01 at 5 11 01 PM

Screenshot 2024-04-01 at 5 11 57 PM proxies已经在代码特别注明了,规则我也写了, 在curl连接和各种vpn检查都做了,vpn是没问题的,但只要一调用api,就会出现connection error,还有什么办法吗? Screenshot 2024-04-01 at 5 11 01 PM

这个是我遇到的error
Screenshot 2024-04-01 at 5 14 01 PM
Screenshot 2024-04-01 at 5 15 11 PM