Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make GPT4FREE support Python 3.8 #1388

Closed
henrik-z4 opened this issue Dec 24, 2023 · 1 comment
Closed

Make GPT4FREE support Python 3.8 #1388

henrik-z4 opened this issue Dec 24, 2023 · 1 comment

Comments

@henrik-z4
Copy link

henrik-z4 commented Dec 24, 2023

Ubuntu 20.04 and lots of other Linux distros are shipped with Python 3.8 preinstalled and they come with apt repos that only have Python 3.8 and not the newest version of python. Uninstalling Python 3.8 ruins the entire operating system, so people are forced to side install the newest version and make it work. Updating python for gpt4free and then dealing with bugs that appear is a nightmare, for me and for other people I met who use this. Moreover, lots of people use their own VPS to store gpt4free. Usually, a VPS comes with Ubuntu 20.04 with Python 3.8 preinstalled. It's very frustrating to make the sideloaded newer version of python work with g4f, as it results in many errors that you should deal with overnight.

I'm not a professional developer yet, but Python 3.8 should have everything for gpt4free to function properly, some changes need to be done to the code though.

For example, you can literally make Bing provider work on Python 3.8 and not throw an error by making a small change to the code in Bing.py, lines 412-419:

'message': Defaults.location | {
                    'author': 'user',
                    'inputMethod': 'Keyboard',
                    'text': prompt,
                    'messageType': 'Chat',
                    'requestId': request_id,
                    'messageId': request_id,
                },

Change the | operator to this:

'message': {**Defaults.location, **{
                    'author': 'user',
                    'inputMethod': 'Keyboard',
                    'text': prompt,
                    'messageType': 'Chat',
                    'requestId': request_id,
                    'messageId': request_id,
                }},

And now it works perfectly fine with Python 3.8

image

Would throw an error Exception has occurred: TypeError: unsupported operand type(s) for |: 'dict' and 'dict'" before though

Correct me if I'm wrong, but I think it might be beneficial to create a version of gpt4free (maybe with a bit limited functionality) that can operate on Python 3.8. This will make lives of dozens and (probably) hundreds of people much easier.

@hlohaus
Copy link
Collaborator

hlohaus commented Dec 25, 2023

#1390

@hlohaus hlohaus closed this as completed Dec 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants