summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/bing/create_images.py
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-01-26 12:49:52 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-01-26 12:49:52 +0100
commit1eb7dc05e59433de149ec16d9b2fe19b3fa4b24b (patch)
tree845e5d27d9f94c16215da60aaee0ad36f5a35344 /g4f/Provider/bing/create_images.py
parentNew minimum requirements (#1515) (diff)
downloadgpt4free-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 'g4f/Provider/bing/create_images.py')
-rw-r--r--g4f/Provider/bing/create_images.py16
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")