TheR1D / shell_gpt

A command-line productivity tool powered by AI large language models like GPT-4, will help you accomplish your tasks faster and more efficiently.
MIT License
9.39k stars 741 forks source link

Network is unreachable #321

Closed captgarrett closed 9 months ago

captgarrett commented 1 year ago

Hi,

Paid chatgpt account + Fresh setup

Error:

ConnectionError: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f65d6b040d0>: Failed to establish a new connection: [Errno 101] Network is unreachable'))

=====

sgptrc

CHAT_CACHE_PATH=/tmp/chat_cache CACHE_PATH=/tmp/cache CHAT_CACHE_LENGTH=100 CACHE_LENGTH=100 REQUEST_TIMEOUT=60 DEFAULT_MODEL=gpt-3.5-turbo OPENAI_API_HOST=https://api.openai.com DEFAULT_COLOR=magenta ROLE_STORAGE_PATH=/home/jgarrett/.config/shell_gpt/roles SYSTEM_ROLES=false DEFAULT_EXECUTE_SHELL_CMD=false DISABLE_STREAMING=false OPENAI_API_KEY=sk-obfuscated

=====

I thought maybe this had something to do with me not having perms, so I tried as root and via sudo from my user and got:

[jgarrett@ssdnodes-64d3d3fc823bb bin]$ sudo python3 sgpt "how do you make a tent?" Traceback (most recent call last): File "/home/jgarrett/.local/bin/sgpt", line 5, in from sgpt import cli ModuleNotFoundError: No module named 'sgpt'

[jgarrett@ssdnodes-64d3d3fc823bb bin]$ ll total 20 -rwxr-xr-x 1 jgarrett jgarrett 212 Aug 10 02:38 distro -rwxr-xr-x 1 jgarrett jgarrett 220 Aug 10 02:38 markdown-it -rwxr-xr-x 1 jgarrett jgarrett 244 Aug 10 02:38 normalizer -rwxr-xr-x 1 jgarrett jgarrett 215 Aug 10 02:38 pygmentize -rwxr-xr-x 1 jgarrett jgarrett 201 Aug 10 03:24 sgpt

======

So then I set it up fresh from root and got the above network error.

I then checked DNS:

[root@ssdnodes-64d3d3fc823bb bin]# dig api.openai.com

; <<>> DiG 9.16.23-RH <<>> api.openai.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54760 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 512 ;; QUESTION SECTION: ;api.openai.com. IN A

;; ANSWER SECTION: api.openai.com. 9 IN A 104.18.6.192 api.openai.com. 9 IN A 104.18.7.192

;; Query time: 38 msec ;; SERVER: 2001:4860:4860::8888#53(2001:4860:4860::8888) ;; WHEN: Thu Aug 10 03:53:53 UTC 2023 ;; MSG SIZE rcvd: 75

====== Secondary question, is it possible to adjust the DEFAULT_MODEL to 4? If so, what's the exact label?

Free-Radical commented 1 year ago

I tried

DEFAULT_MODEL=gpt-4

in ~/.config/shell_gpt/.sgptrc

but claims to still be using GPT-3


❯ sgpt "are you using GPT-4"
No, I am based on GPT-3 model.

❯ sgpt "are you GPT-4"
No, I am ShellGPT, a model based on OpenAI's GPT-3.
cryolite-ai commented 1 year ago

@captgarrett the issues page is being overwhelmed now with stuff which isn't actually an issue with the software - much of your posting falls into that category. Can I suggest as a strategy before posting an issue on github, you paste your error message into either ChatGPT or Claude.Ai.. here's Claude's ouptut:

It looks like there may be a few issues going on here:

  • The initial error suggests that sgpt is unable to connect to the OpenAI API due to a network connectivity issue. This could be caused by a firewall, proxy, or other network configuration blocking access.

  • When running sgpt with sudo, you get a ModuleNotFoundError, which indicates sgpt isn't properly installed for the root user. Usually Python packages are installed in a user's local environment, so sudo doesn't have access.

  • The dig command shows that you are able to resolve the API hostname, so DNS itself seems to be working.

Some things to try:

  • Check for any firewall rules, proxies, or other network restrictions that could be blocking access to api.openai.com on ports 443 or 80. Temporarily disabling firewalls like ufw can help narrow down the issue.

  • Reinstall sgpt using pip while running as root, e.g. sudo pip install sgpt. This will do a root install that sudo can access.

  • Try running sgpt as your regular user over VPN or another network, in case your local network has restrictions.

  • Use curl or telnet to check basic TCP/IP connectivity to api.openai.com ports 443 and 80 from the server.

  • Double check the API key is valid and correctly set in the sgpt config.

Hope this gives you some ideas on troubleshooting further! Let me know if any of those suggestions help resolve the connectivity issues.

Actually I think in the first bit you wrote - the networking section - you may not have realised there are rate-limits on OpenAI's API access and that your URL request rate may have hit them.. in your permissions sudo bit, I don't think you understand what PATHs are under unix (and you should get an AI to tutor you on that)

Finally, for your 'secondary question', I need to point out that mixing questions by tacking an extra one on is bad for you and bad for the issues stack - it's bad for you because people will easily miss something they could help you with because it doesn't match the title and it's bad for the issue stack because if someone does answer it in the thread then nobody who has the same problem will easily spot it because it's under the wrong title.

So, please, to help this place function (because I'm worried that the original author will now be overwhelmed with questions which aren't actually their problem), can I gently ask you:

(a) put your error message through an LLM first for suggestions before turning to the volunteer author and (b) stick to one specific issue which matches what you have in the title

@Free-Radical - I don't know if the issue is still there for you, when I tried

sgpt "which version of GPT is running?"

I got I am running GPT-3.5.2.

@TheR1D I think you can mark this issue as closed - it seems to have been mostly a user-support issue not a software issue. Hope this helps to deal with the backlog of issues - seems to me a lot of them aren't really shell-gpt problems per se. Best regards and thanks for building this tool.

TheR1D commented 9 months ago

Closing this issue due to its age and lack of similar reports/requests from other users.