xtekky / gpt4free

The official gpt4free repository | various collection of powerful language models
https://g4f.ai
GNU General Public License v3.0
61.2k stars 13.33k forks source link

Error - Debian Server Python #1699

Closed max1mde closed 7 months ago

max1mde commented 8 months ago

Bug description I installed gpt4free through pip on my debian 12 server and installed chrome using this guide: https://github.com/password123456/setup-selenium-with-chrome-driver-on-ubuntu_debian

Error:

Traceback (most recent call last):
  File "/home/ai/main.py", line 6, in <module>
    response = client.chat.completions.create(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/g4f/client.py", line 163, in create
    return response if stream else next(response)
                                   ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/g4f/client.py", line 84, in iter_append_model_and_provider
    for chunk in response:
  File "/usr/local/lib/python3.11/dist-packages/g4f/client.py", line 49, in iter_response
    for idx, chunk in enumerate(response):
  File "/usr/local/lib/python3.11/dist-packages/g4f/providers/retry_provider.py", line 81, in create_completion
    raise_exceptions(exceptions)
  File "/usr/local/lib/python3.11/dist-packages/g4f/providers/retry_provider.py", line 201, in raise_exceptions
    raise RetryProviderError("RetryProvider failed:\n" + "\n".join([
g4f.errors.RetryProviderError: RetryProvider failed:
GptGo: RuntimeError: Response: error token
Chatgpt4Online: WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:44005
from chrome not reachable
Stacktrace:
#0 0x55994f66bf33 <unknown>
#1 0x55994f363b37 <unknown>
#2 0x55994f34ea13 <unknown>
#3 0x55994f39d601 <unknown>
#4 0x55994f39416b <unknown>
#5 0x55994f3dd71c <unknown>
#6 0x55994f3d0c53 <unknown>
#7 0x55994f3a1db3 <unknown>
#8 0x55994f3a277e <unknown>
#9 0x55994f63186b <unknown>
#10 0x55994f635885 <unknown>
#11 0x55994f61f181 <unknown>
#12 0x55994f636412 <unknown>
#13 0x55994f60325f <unknown>
#14 0x55994f65a528 <unknown>
#15 0x55994f65a723 <unknown>
#16 0x55994f66b0e4 <unknown>
#17 0x7f7f241f2044 <unknown>

GptForLove: ProgramError: Error: Cannot find module '/usr/local/lib/python3.11/dist-packages/g4f/Provider/not_working/npm/node_modules/crypto-js/crypto-js'
Require stack:
- /home/ai/[stdin]
ChatBase: ClientResponseError: 429, message='Too Many Requests', url=URL('https://www.chatbase.co/api/fe/chat')
You: WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:60113
from chrome not reachable
Stacktrace:
#0 0x55f007a11f33 <unknown>
#1 0x55f007709b37 <unknown>
#2 0x55f0076f4a13 <unknown>
#3 0x55f007743601 <unknown>
#4 0x55f00773a16b <unknown>
#5 0x55f00778371c <unknown>
#6 0x55f007776c53 <unknown>
#7 0x55f007747db3 <unknown>
#8 0x55f00774877e <unknown>
#9 0x55f0079d786b <unknown>
#10 0x55f0079db885 <unknown>
#11 0x55f0079c5181 <unknown>
#12 0x55f0079dc412 <unknown>
#13 0x55f0079a925f <unknown>
#14 0x55f007a00528 <unknown>
#15 0x55f007a00723 <unknown>
#16 0x55f007a110e4 <unknown>
#17 0x7f7c45a26044 <unknown>

root@mxm:~/home/ai# 

Environment

The python file:

from g4f.client import Client

client = Client()

while True:
    response = client.chat.completions.create(
        model="gpt-3.5-turbo",
        messages=[{"role": "user", "content": input("Your question?\n")}],
    )
    print(response.choices[0].message.content)
hlohaus commented 8 months ago

Selenium is a little bit unstable. You should reuse the Webdriver if possible. A example are in the docs. Also you are using a old version of g4f. Please update it.

max1mde commented 8 months ago

image isnt that the newest version?

max1mde commented 8 months ago

What do you mean by reusing the Webdriver? Didnt find anything... Also im using a linux server without a gui so idk if this is even working with a browser

hlohaus commented 8 months ago

Our Docker Image is a working Ubuntu/Debian Server. Yes, it need some special configuration to run Google Chrome. In the docs are a part about the Webdriver:

/docs/legacy.md > Using Browser

You can also use other Providers. They need only some configuration. Like OpenaiChat or GeminiPro

max1mde commented 8 months ago

Could I just use providers which dont need a browser? Do free APIs exist?

hlohaus commented 8 months ago

You could disable the Webdriver with:

pip uninstall undetected-chromedriver

Then only providers with this requirement try using it.

Yes there are free apis. Like OpenaiChat with access_token from the Web chat or GeminiPro with a free api_key for user outside europe.

github-actions[bot] commented 8 months ago

Bumping this issue because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again.

github-actions[bot] commented 7 months ago

Closing due to inactivity.