summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/bing
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-01-27 16:09:21 +0100
committerGitHub <noreply@github.com>2024-01-27 16:09:21 +0100
commit0d83bdeef91001c7c00d69f79fccad5a78b4b94b (patch)
tree362ebeb245cc4e123914635b03f890a314a7a40d /g4f/Provider/bing
parentMerge pull request #1512 from KennyPhan123/patch-1 (diff)
parentFix PerplexityLabs Provider, Improve bypass_cloudflare helper (diff)
downloadgpt4free-0d83bdeef91001c7c00d69f79fccad5a78b4b94b.tar
gpt4free-0d83bdeef91001c7c00d69f79fccad5a78b4b94b.tar.gz
gpt4free-0d83bdeef91001c7c00d69f79fccad5a78b4b94b.tar.bz2
gpt4free-0d83bdeef91001c7c00d69f79fccad5a78b4b94b.tar.lz
gpt4free-0d83bdeef91001c7c00d69f79fccad5a78b4b94b.tar.xz
gpt4free-0d83bdeef91001c7c00d69f79fccad5a78b4b94b.tar.zst
gpt4free-0d83bdeef91001c7c00d69f79fccad5a78b4b94b.zip
Diffstat (limited to 'g4f/Provider/bing')
-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")