diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-01-27 16:09:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-27 16:09:21 +0100 |
commit | 0d83bdeef91001c7c00d69f79fccad5a78b4b94b (patch) | |
tree | 362ebeb245cc4e123914635b03f890a314a7a40d /g4f/Provider/bing | |
parent | Merge pull request #1512 from KennyPhan123/patch-1 (diff) | |
parent | Fix PerplexityLabs Provider, Improve bypass_cloudflare helper (diff) | |
download | gpt4free-0.2.0.7.tar gpt4free-0.2.0.7.tar.gz gpt4free-0.2.0.7.tar.bz2 gpt4free-0.2.0.7.tar.lz gpt4free-0.2.0.7.tar.xz gpt4free-0.2.0.7.tar.zst gpt4free-0.2.0.7.zip |
Diffstat (limited to 'g4f/Provider/bing')
-rw-r--r-- | g4f/Provider/bing/create_images.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/g4f/Provider/bing/create_images.py b/g4f/Provider/bing/create_images.py index 4fa85929..a3fcd91b 100644 --- a/g4f/Provider/bing/create_images.py +++ b/g4f/Provider/bing/create_images.py @@ -202,16 +202,15 @@ class CreateImagesBing: Yields: Generator[str, None, None]: The final output as markdown formatted string with images. """ - try: - cookies = self.cookies or get_cookies(".bing.com") - except MissingRequirementsError as e: - raise MissingAccessToken(f'Missing "_U" cookie. {e}') - + cookies = self.cookies or get_cookies(".bing.com", False) if "_U" not in cookies: login_url = os.environ.get("G4F_LOGIN_URL") if login_url: yield f"Please login: [Bing]({login_url})\n\n" - self.cookies = get_cookies_from_browser(self.proxy) + try: + self.cookies = get_cookies_from_browser(self.proxy) + except MissingRequirementsError as e: + raise MissingAccessToken(f'Missing "_U" cookie. {e}') yield asyncio.run(self.create_async(prompt)) async def create_async(self, prompt: str) -> ImageResponse: @@ -224,10 +223,7 @@ class CreateImagesBing: Returns: str: Markdown formatted string with images. """ - try: - cookies = self.cookies or get_cookies(".bing.com") - except MissingRequirementsError as e: - raise MissingAccessToken(f'Missing "_U" cookie. {e}') + cookies = self.cookies or get_cookies(".bing.com", False) if "_U" not in cookies: raise MissingAccessToken('Missing "_U" cookie') proxy = os.environ.get("G4F_PROXY") |