diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-11-19 20:53:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-19 20:53:11 +0100 |
commit | de4f374c5d01216cf62ba3594cff3762a1fd8159 (patch) | |
tree | 7dd083571e2396a627dfd468f21af8402cc39f2d /g4f/Provider/Copilot.py | |
parent | Merge pull request #2382 from hlohaus/info (diff) | |
parent | Add --cookie-browsers argument to cli (diff) | |
download | gpt4free-0.3.5.1.tar gpt4free-0.3.5.1.tar.gz gpt4free-0.3.5.1.tar.bz2 gpt4free-0.3.5.1.tar.lz gpt4free-0.3.5.1.tar.xz gpt4free-0.3.5.1.tar.zst gpt4free-0.3.5.1.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/Provider/Copilot.py | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/g4f/Provider/Copilot.py b/g4f/Provider/Copilot.py index c79f028d..e40278c7 100644 --- a/g4f/Provider/Copilot.py +++ b/g4f/Provider/Copilot.py @@ -15,17 +15,13 @@ try: has_nodriver = True except ImportError: has_nodriver = False -try: - from platformdirs import user_config_dir - has_platformdirs = True -except ImportError: - has_platformdirs = False from .base_provider import AbstractProvider, BaseConversation from .helper import format_prompt from ..typing import CreateResult, Messages, ImageType from ..errors import MissingRequirementsError from ..requests.raise_for_status import raise_for_status +from ..requests import get_nodriver from ..image import to_bytes, is_accepted_format from .. import debug @@ -130,6 +126,7 @@ class Copilot(AbstractProvider): except: break if msg.get("event") == "appendText": + is_started = True yield msg.get("text") elif msg.get("event") in ["done", "partCompleted"]: break @@ -138,14 +135,7 @@ class Copilot(AbstractProvider): @classmethod async def get_access_token_and_cookies(cls, proxy: str = None): - if not has_nodriver: - raise MissingRequirementsError('Install "nodriver" package | pip install -U nodriver') - user_data_dir = user_config_dir("g4f-nodriver") if has_platformdirs else None - debug.log(f"Copilot: Open nodriver with user_dir: {user_data_dir}") - browser = await nodriver.start( - user_data_dir=user_data_dir, - browser_args=None if proxy is None else [f"--proxy-server={proxy}"], - ) + browser = await get_nodriver(proxy=proxy) page = await browser.get(cls.url) access_token = None while access_token is None: |