diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-01-26 12:49:52 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-01-26 12:49:52 +0100 |
commit | 1eb7dc05e59433de149ec16d9b2fe19b3fa4b24b (patch) | |
tree | 845e5d27d9f94c16215da60aaee0ad36f5a35344 /g4f/Provider/needs_auth/OpenaiChat.py | |
parent | New minimum requirements (#1515) (diff) | |
download | gpt4free-1eb7dc05e59433de149ec16d9b2fe19b3fa4b24b.tar gpt4free-1eb7dc05e59433de149ec16d9b2fe19b3fa4b24b.tar.gz gpt4free-1eb7dc05e59433de149ec16d9b2fe19b3fa4b24b.tar.bz2 gpt4free-1eb7dc05e59433de149ec16d9b2fe19b3fa4b24b.tar.lz gpt4free-1eb7dc05e59433de149ec16d9b2fe19b3fa4b24b.tar.xz gpt4free-1eb7dc05e59433de149ec16d9b2fe19b3fa4b24b.tar.zst gpt4free-1eb7dc05e59433de149ec16d9b2fe19b3fa4b24b.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/Provider/needs_auth/OpenaiChat.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/g4f/Provider/needs_auth/OpenaiChat.py b/g4f/Provider/needs_auth/OpenaiChat.py index b07bd49b..60a101d7 100644 --- a/g4f/Provider/needs_auth/OpenaiChat.py +++ b/g4f/Provider/needs_auth/OpenaiChat.py @@ -16,9 +16,8 @@ try: from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC - has_webdriver = True except ImportError: - has_webdriver = False + pass from ..base_provider import AsyncGeneratorProvider, ProviderModelMixin from ..helper import format_prompt, get_cookies @@ -332,13 +331,14 @@ class OpenaiChat(AsyncGeneratorProvider, ProviderModelMixin): cookies = cls._cookies or get_cookies("chat.openai.com", False) if not access_token and "access_token" in cookies: access_token = cookies["access_token"] - if not access_token and not has_webdriver: - raise MissingAccessToken(f'Missing "access_token"') if not access_token: login_url = os.environ.get("G4F_LOGIN_URL") if login_url: yield f"Please login: [ChatGPT]({login_url})\n\n" - access_token, cookies = cls.browse_access_token(proxy) + try: + access_token, cookies = cls.browse_access_token(proxy) + except MissingRequirementsError: + raise MissingAccessToken(f'Missing "access_token"') cls._cookies = cookies headers = {"Authorization": f"Bearer {access_token}"} |