From ea8d6b847a0e656cc5583948c5745592adda7103 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Sat, 13 Jan 2024 15:37:36 +0100 Subject: Support upload image in gui Add image upload to OpenaiChat Add image response to OpenaiChat Improve ChatGPT Plus Support Remove unused requirements --- g4f/Provider/Bing.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'g4f/Provider/Bing.py') 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 -- cgit v1.2.3