diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-01-13 15:37:36 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-01-13 15:37:36 +0100 |
commit | ea8d6b847a0e656cc5583948c5745592adda7103 (patch) | |
tree | cb796ff258d339a5ee4a4ec3fb4b2617e6639677 /g4f/Provider/Bing.py | |
parent | Change pypi to live (diff) | |
download | gpt4free-ea8d6b847a0e656cc5583948c5745592adda7103.tar gpt4free-ea8d6b847a0e656cc5583948c5745592adda7103.tar.gz gpt4free-ea8d6b847a0e656cc5583948c5745592adda7103.tar.bz2 gpt4free-ea8d6b847a0e656cc5583948c5745592adda7103.tar.lz gpt4free-ea8d6b847a0e656cc5583948c5745592adda7103.tar.xz gpt4free-ea8d6b847a0e656cc5583948c5745592adda7103.tar.zst gpt4free-ea8d6b847a0e656cc5583948c5745592adda7103.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/Provider/Bing.py | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/g4f/Provider/Bing.py b/g4f/Provider/Bing.py index b0949397..da9b0172 100644 --- a/g4f/Provider/Bing.py +++ b/g4f/Provider/Bing.py @@ -8,11 +8,10 @@ import time from urllib import parse from aiohttp import ClientSession, ClientTimeout -from ..typing import AsyncResult, Messages +from ..typing import AsyncResult, Messages, ImageType from .base_provider import AsyncGeneratorProvider -from ..webdriver import get_browser, get_driver_cookies from .bing.upload_image import upload_image -from .bing.create_images import create_images, format_images_markdown, wait_for_login +from .bing.create_images import create_images, format_images_markdown from .bing.conversation import Conversation, create_conversation, delete_conversation class Tones(): @@ -34,7 +33,7 @@ class Bing(AsyncGeneratorProvider): timeout: int = 900, cookies: dict = None, tone: str = Tones.balanced, - image: str = None, + image: ImageType = None, web_search: bool = False, **kwargs ) -> AsyncResult: @@ -247,7 +246,7 @@ def create_message( async def stream_generate( prompt: str, tone: str, - image: str = None, + image: ImageType = None, context: str = None, proxy: str = None, cookies: dict = None, @@ -315,14 +314,7 @@ async def stream_generate( result = response['item']['result'] if result.get('error'): if result["value"] == "CaptchaChallenge": - driver = get_browser(proxy=proxy) - try: - wait_for_login(driver) - cookies = get_driver_cookies(driver) - finally: - driver.quit() - async for chunk in stream_generate(prompt, tone, image, context, proxy, cookies, web_search, gpt4_turbo, timeout): - yield chunk + raise Exception(f"{result['value']}: Use other cookies or/and ip address") else: raise Exception(f"{result['value']}: {result['message']}") return |