From 1eb7dc05e59433de149ec16d9b2fe19b3fa4b24b Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Fri, 26 Jan 2024 12:49:52 +0100 Subject: Fix: ChromeDriver only supports characters in the BMP Add set_cookies helper, Show last used model --- g4f/Provider/bing/create_images.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'g4f/Provider/bing') 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") -- cgit v1.2.3