From 69ef224f92fcec3335a857305191678b886651e1 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Wed, 24 Jan 2024 00:46:35 +0100 Subject: Add get_connector helper --- g4f/Provider/Bing.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'g4f/Provider/Bing.py') diff --git a/g4f/Provider/Bing.py b/g4f/Provider/Bing.py index 751b0d3a..11bb1414 100644 --- a/g4f/Provider/Bing.py +++ b/g4f/Provider/Bing.py @@ -11,6 +11,7 @@ from aiohttp import ClientSession, ClientTimeout, BaseConnector from ..typing import AsyncResult, Messages, ImageType from ..image import ImageResponse from .base_provider import AsyncGeneratorProvider +from .helper import get_connector from .bing.upload_image import upload_image from .bing.create_images import create_images from .bing.conversation import Conversation, create_conversation, delete_conversation @@ -68,15 +69,8 @@ class Bing(AsyncGeneratorProvider): cookies = {**Defaults.cookies, **cookies} if cookies else Defaults.cookies gpt4_turbo = True if model.startswith("gpt-4-turbo") else False - - if proxy and not connector: - try: - from aiohttp_socks import ProxyConnector - connector = ProxyConnector.from_url(proxy) - except ImportError: - raise RuntimeError('Install "aiohttp_socks" package for proxy support') - return stream_generate(prompt, tone, image, context, cookies, connector, web_search, gpt4_turbo, timeout) + return stream_generate(prompt, tone, image, context, cookies, get_connector(connector, proxy), web_search, gpt4_turbo, timeout) def create_context(messages: Messages) -> str: """ -- cgit v1.2.3