diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-05-16 20:06:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-16 20:06:57 +0200 |
commit | 0332c0c0dd01dd71aabca62f007ad9e8809ee48f (patch) | |
tree | f9a4170ef8c5b0358bc4cf7189f997e3098ee0f3 /g4f/Provider/needs_auth/OpenaiChat.py | |
parent | Update README.md (diff) | |
parent | Add needs auth to provierds, Add PerplexityApi provider (diff) | |
download | gpt4free-0332c0c0dd01dd71aabca62f007ad9e8809ee48f.tar gpt4free-0332c0c0dd01dd71aabca62f007ad9e8809ee48f.tar.gz gpt4free-0332c0c0dd01dd71aabca62f007ad9e8809ee48f.tar.bz2 gpt4free-0332c0c0dd01dd71aabca62f007ad9e8809ee48f.tar.lz gpt4free-0332c0c0dd01dd71aabca62f007ad9e8809ee48f.tar.xz gpt4free-0332c0c0dd01dd71aabca62f007ad9e8809ee48f.tar.zst gpt4free-0332c0c0dd01dd71aabca62f007ad9e8809ee48f.zip |
Diffstat (limited to 'g4f/Provider/needs_auth/OpenaiChat.py')
-rw-r--r-- | g4f/Provider/needs_auth/OpenaiChat.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/g4f/Provider/needs_auth/OpenaiChat.py b/g4f/Provider/needs_auth/OpenaiChat.py index 03ea4539..b4b8bb02 100644 --- a/g4f/Provider/needs_auth/OpenaiChat.py +++ b/g4f/Provider/needs_auth/OpenaiChat.py @@ -403,7 +403,7 @@ class OpenaiChat(AsyncGeneratorProvider, ProviderModelMixin): except NoValidHarFileError as e: error = e if cls._api_key is None: - await cls.nodriver_access_token() + await cls.nodriver_access_token(proxy) if cls._api_key is None and cls.needs_auth: raise error cls.default_model = cls.get_model(await cls.get_default_model(session, cls._headers)) @@ -625,7 +625,7 @@ this.fetch = async (url, options) => { cls._update_cookie_header() @classmethod - async def nodriver_access_token(cls): + async def nodriver_access_token(cls, proxy: str = None): try: import nodriver as uc except ImportError: @@ -637,7 +637,10 @@ this.fetch = async (url, options) => { user_data_dir = None if debug.logging: print(f"Open nodriver with user_dir: {user_data_dir}") - browser = await uc.start(user_data_dir=user_data_dir) + browser = await uc.start( + user_data_dir=user_data_dir, + browser_args=None if proxy is None else [f"--proxy-server={proxy}"], + ) page = await browser.get("https://chatgpt.com/") await page.select("[id^=headlessui-menu-button-]", 240) api_key = await page.evaluate( |