AutoGPT icon indicating copy to clipboard operation
AutoGPT copied to clipboard

enable Google/OpenAI access for china mainland users

Open youkaichao opened this issue 1 year ago • 18 comments

Background

China mainland users usually have difficulty accessing Google and OpenAI service via commandline or selenium.

Changes

  • Enable the custom webdriver path for manual installation of the webdriver.
  • Enable user data directory for selenium-invoked Chrome so that users' usualy proxy can be leveraged.
  • Document in README that they can provide https_proxy environment variable to access Internet via commandline.

Documentation

Both in-code comments and README documentations are provided.

Test Plan

I have tested the procedure on my laptop.

PR Quality Checklist

  • [x] My pull request is atomic and focuses on a single change.
  • [ ] I have thoroughly tested my changes with multiple different prompts. (Do not apply.)
  • [x] I have considered potential risks and mitigations for my changes.
  • [x] I have documented my changes clearly and comprehensively.
  • [x] I have not snuck in any "extra" small tweaks changes

youkaichao avatar Apr 15 '23 11:04 youkaichao

This PR does not affect users out of China mainland (because default switches are off). But they are valuable for China mainland users so that they can easily configure Auto-GPT to run!

youkaichao avatar Apr 15 '23 11:04 youkaichao

chatGPT可以正常使用,网络连接应该没有问题,但是auto-GPT跑不起来,是这样的问题吗? 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)')))

loseDemon avatar Apr 15 '23 12:04 loseDemon

I got same error.whatever I do, it always jump out this error.

Wang DaChui @.***> 于2023年4月15日周六 20:37写道:

chatGPT可以正常使用,网络连接应该没有问题,但是auto-GPT跑不起来,是这样的问题吗? 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)')))

— Reply to this email directly, view it on GitHub https://github.com/Significant-Gravitas/Auto-GPT/pull/1541#issuecomment-1509766229, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB3MFYMCNG3OZPIQQLWPZELXBKI7BANCNFSM6AAAAAAW7KZA6Y . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Mandolilele avatar Apr 15 '23 12:04 Mandolilele

我有同样的错误。无论我做什么,它总是跳出这个错误。王大锤***@.>于2023年4月15日周六20:37写道: …… chatGPT可以正常使用,网络连接应该没有问题,但是auto-GPT跑不起来,是这样的问题吗? com', port=443): 最大重试次数超过 url: /v1/chat/completions (由 SSLError(SSLOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))) — 回复直接在 GitHub < #1541(评论) >上查看此电子邮件,或取消订阅 < https://github.com/notifications/unsubscribe-auth/AB3MFYMCNG3OZPIQQLWPZELXBKI7BANCNFSM6AAAAAAW7KZA6Y >。您收到此邮件是因为您订阅了此线程。消息 ID : @.***> 最后解决了吗?老哥

loseDemon avatar Apr 15 '23 12:04 loseDemon

@youkaichao There are conflicts now

nponeccop avatar Apr 15 '23 13:04 nponeccop

@loseDemon @olymax Did you set the https_proxy environment variable?

For example, my command is:

https_proxy=http://127.0.0.1:9090 python -m autogpt --gpt3only

Remember to replace the specific https_proxy with your own proxy url.

youkaichao avatar Apr 15 '23 13:04 youkaichao

@youkaichao There are conflicts now

nponeccop avatar Apr 15 '23 13:04 nponeccop

@nponeccop I'm working on the conflict. It should be done in several minutes.

youkaichao avatar Apr 15 '23 13:04 youkaichao

@nponeccop The conflicts should be resolved now.

youkaichao avatar Apr 15 '23 13:04 youkaichao

I just tested this PR combined with the fix of type annotation: https://github.com/Significant-Gravitas/Auto-GPT/pull/1580 . They should work now.

youkaichao avatar Apr 15 '23 14:04 youkaichao

按照文件里下载了谷歌驱动,在对应脚本里添加了相应的命令。鼓捣半天实在连接不上,可能是我太小白了。。

(venv) PS G:\Project_Python\Auto-GPT-master> python -m autogpt --gpt3only
pymilvus not installed. Skipping import.
GPT3.5 Only Mode:  ENABLED
Welcome to Auto-GPT!  Enter the name of your AI and its role below. Entering nothing will load defaults.
Name your AI:  For example, 'Entrepreneur-GPT'
AI Name: AI1
AI1 here!  I am at your service.
Describe your AI's role:  For example, 'an AI designed to autonomously develop and run businesses with the sole goal of increasing your net worth.'
AI1 is: 写一个网页
Enter up to 5 goals for your AI:  For example: Increase net worth, Grow Twitter Account, Develop and manage multiple businesses autonomously'
Enter nothing to load defaults, enter nothing when finished.
Goal 1: 包括登录界面
Goal 2: 
Using memory of type:  LocalCache
Using Browser:  chrome
Traceback (most recent call last):
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\util\connection.py", line 95, in create_connection
    raise err
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\util\connection.py", line 85, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\connection.py", line 363, in connect
    self.sock = conn = self._new_conn()
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x0000012E0E5CC820>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\requests\adapters.py", line 489, in send
    resp = conn.urlopen(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\connectionpool.py", line 815, in urlopen
    return self.urlopen(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\connectionpool.py", line 815, in urlopen
    return self.urlopen(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\util\retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000012E0E5CC
820>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\openai\api_requestor.py", line 516, in request_raw
    result = _thread_context.session.request(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\requests\sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\requests\sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\requests\adapters.py", line 565, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000012E0E
5CC820>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))

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

Traceback (most recent call last):
  File "D:\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\Python\Python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "G:\Project_Python\Auto-GPT-master\autogpt\__main__.py", line 51, in <module>
    main()
  File "G:\Project_Python\Auto-GPT-master\autogpt\__main__.py", line 47, in main
    agent.start_interaction_loop()
  File "G:\Project_Python\Auto-GPT-master\autogpt\agent\agent.py", line 65, in start_interaction_loop
    assistant_reply = chat_with_ai(
  File "G:\Project_Python\Auto-GPT-master\autogpt\chat.py", line 159, in chat_with_ai
    assistant_reply = create_chat_completion(
  File "G:\Project_Python\Auto-GPT-master\autogpt\llm_utils.py", line 90, in create_chat_completion
    response = openai.ChatCompletion.create(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\openai\api_resources\chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\openai\api_requestor.py", line 216, in request
    result = self.request_raw(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\openai\api_requestor.py", line 528, in request_raw
    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 NewConnectionError('<urllib3.connection.HTTPSConn
ection object at 0x0000012E0E5CC820>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))

zxcvcxz12345 avatar Apr 15 '23 17:04 zxcvcxz12345

@nponeccop I resolved conflicts via commit 6b6d0ad .

youkaichao avatar Apr 16 '23 02:04 youkaichao

@zxcvcxz12345 看起来还是你的代理没有配置好。你需要检查Windows命令行使用代理的方式,或者换用Linux/Windows Linux Subsystem (WSL).

youkaichao avatar Apr 16 '23 02:04 youkaichao

按照文件里下载了谷歌驱动,在对应脚本里添加了相应的命令。鼓捣半天实在连接不上,可能是我太小白了。。

(venv) PS G:\Project_Python\Auto-GPT-master> python -m autogpt --gpt3only
pymilvus not installed. Skipping import.
GPT3.5 Only Mode:  ENABLED
Welcome to Auto-GPT!  Enter the name of your AI and its role below. Entering nothing will load defaults.
Name your AI:  For example, 'Entrepreneur-GPT'
AI Name: AI1
AI1 here!  I am at your service.
Describe your AI's role:  For example, 'an AI designed to autonomously develop and run businesses with the sole goal of increasing your net worth.'
AI1 is: 写一个网页
Enter up to 5 goals for your AI:  For example: Increase net worth, Grow Twitter Account, Develop and manage multiple businesses autonomously'
Enter nothing to load defaults, enter nothing when finished.
Goal 1: 包括登录界面
Goal 2: 
Using memory of type:  LocalCache
Using Browser:  chrome
Traceback (most recent call last):
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\util\connection.py", line 95, in create_connection
    raise err
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\util\connection.py", line 85, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\connection.py", line 363, in connect
    self.sock = conn = self._new_conn()
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x0000012E0E5CC820>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\requests\adapters.py", line 489, in send
    resp = conn.urlopen(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\connectionpool.py", line 815, in urlopen
    return self.urlopen(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\connectionpool.py", line 815, in urlopen
    return self.urlopen(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\urllib3\util\retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000012E0E5CC
820>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\openai\api_requestor.py", line 516, in request_raw
    result = _thread_context.session.request(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\requests\sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\requests\sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\requests\adapters.py", line 565, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000012E0E
5CC820>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))

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

Traceback (most recent call last):
  File "D:\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\Python\Python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "G:\Project_Python\Auto-GPT-master\autogpt\__main__.py", line 51, in <module>
    main()
  File "G:\Project_Python\Auto-GPT-master\autogpt\__main__.py", line 47, in main
    agent.start_interaction_loop()
  File "G:\Project_Python\Auto-GPT-master\autogpt\agent\agent.py", line 65, in start_interaction_loop
    assistant_reply = chat_with_ai(
  File "G:\Project_Python\Auto-GPT-master\autogpt\chat.py", line 159, in chat_with_ai
    assistant_reply = create_chat_completion(
  File "G:\Project_Python\Auto-GPT-master\autogpt\llm_utils.py", line 90, in create_chat_completion
    response = openai.ChatCompletion.create(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\openai\api_resources\chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\openai\api_requestor.py", line 216, in request
    result = self.request_raw(
  File "G:\Project_Python\Auto-GPT-master\venv\lib\site-packages\openai\api_requestor.py", line 528, in request_raw
    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 NewConnectionError('<urllib3.connection.HTTPSConn
ection object at 0x0000012E0E5CC820>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))

你这里是 openai 都没连上。 检查一下 token 有没有设置正确,以及代理有没有设置好。

RadixIsatidis avatar Apr 16 '23 03:04 RadixIsatidis

I am new to study how to use github issues. Yesterday I didn't apply my google api key and PINECONE_API_KEY.Today I apply them, and then change the .env file, But every time I use google command, it returns" Command google returned: Error: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接 的主机没有反应,连接尝试失败。" Is that means I have to check 我自己的代理URL every time before use it?(I'm sorry that I am lacking in web knowledge so I have to try to express my meaning correctly.)

是否设置了环境变量?https_proxy

例如,我的命令是:

https_proxy=http://127.0.0.1:9090 python -m autogpt --gpt3only

请记住将特定https_proxy替换为您自己的代理 URL。

kazegairoman avatar Apr 16 '23 09:04 kazegairoman

and I try to use it,I found that-- image image

kazegairoman avatar Apr 16 '23 09:04 kazegairoman

@kazegairoman My example is for Linux/MacOS. For Windows, you have to know how to set proxy for commandline, for example, https://stackoverflow.com/a/57613619 . Sorry that I'm not familiar with Windows. I recommend using Linux or just WSL.

youkaichao avatar Apr 16 '23 10:04 youkaichao

thank you so much! I had already solved this question!

kazegairoman avatar Apr 16 '23 12:04 kazegairoman

按要求下载并配置了,还是提示。SYSTEM: Command google returned: Error: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。 image

kuok246 avatar Apr 17 '23 02:04 kuok246

@kuok246 我的示例适用于 Linux/MacOS。 对于 Windows,您必须知道如何为命令行设置代理,例如,stackoverflow.com/a/57613619。 对不起,我不熟悉Windows。 我建议使用 Linux 或使用 WSL。

youkaichao avatar Apr 17 '23 03:04 youkaichao

https_proxy=http://127.0.0.1:9090 python -m autogpt --gpt3only

请问10060的报错如何处理吖?

Maxwongfong avatar Apr 17 '23 03:04 Maxwongfong

@Maxwongfong 我的示例适用于 Linux/MacOS。 对于 Windows,您必须知道如何为命令行设置代理,例如,stackoverflow.com/a/57613619。 对不起,我不熟悉Windows。 我建议使用 Linux 或使用 WSL。

youkaichao avatar Apr 17 '23 05:04 youkaichao

thank you so much! I had already solved this question! Could you tell me how to solve it

BadwomenzzzZ avatar Apr 17 '23 08:04 BadwomenzzzZ

在windows中将cmd的代理服务器地址设置为梯子的代理服务器地址 然后解决了这个问题。命令为 set http_proxy=http://127.0.0.1:端口号 set https_proxy=http://127.0.0.1:端口号

dingpf08 avatar Apr 17 '23 14:04 dingpf08

@dingpf08 thank you! I have added the method to the README.

youkaichao avatar Apr 17 '23 15:04 youkaichao

I'm concerned with complexifying the repo while it is in early stages of growth and has not yet had time to solidify.

I would prefer to be looking at building region-specific issues into the core NOT UNTIL the core has stabilized.

And why mention China specifically? How about Italy/Germany that have banned ChatGPT?

p-i- avatar Apr 17 '23 15:04 p-i-

@p-i- I don't know how Italy/Germany ban ChatGPT. Mainland China has great firewall (GFW). So developers from China constantly need to address issues like proxy. Adding this to README can address many issues. The issue area in this repo can be less busy :)

youkaichao avatar Apr 17 '23 15:04 youkaichao

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

github-actions[bot] avatar Apr 17 '23 18:04 github-actions[bot]

在windows中将cmd的代理服务器地址设置为梯子的代理服务器地址 然后解决了这个问题。命令为

set http_proxy=http://127.0.0.1:端口号

set https_proxy=http://127.0.0.1:端口号

昨晚换了一个思路解决了,这个问题之前就有出现。是Google dns服务器设置的问题,设置好就行。梯子ip太多,经常改变。

Maxwongfong avatar Apr 17 '23 21:04 Maxwongfong

I withdraw my objection to merging, if the conflicts are resolved.

p-i- avatar Apr 18 '23 01:04 p-i-