summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/bing/create_images.py
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-01-24 00:46:35 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-01-24 00:46:35 +0100
commit69ef224f92fcec3335a857305191678b886651e1 (patch)
treee2eb38fc678c68fa75b06631880172d164a9c7e7 /g4f/Provider/bing/create_images.py
parentAdd aiohttp_socks support (diff)
downloadgpt4free-69ef224f92fcec3335a857305191678b886651e1.tar
gpt4free-69ef224f92fcec3335a857305191678b886651e1.tar.gz
gpt4free-69ef224f92fcec3335a857305191678b886651e1.tar.bz2
gpt4free-69ef224f92fcec3335a857305191678b886651e1.tar.lz
gpt4free-69ef224f92fcec3335a857305191678b886651e1.tar.xz
gpt4free-69ef224f92fcec3335a857305191678b886651e1.tar.zst
gpt4free-69ef224f92fcec3335a857305191678b886651e1.zip
Diffstat (limited to 'g4f/Provider/bing/create_images.py')
-rw-r--r--g4f/Provider/bing/create_images.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/g4f/Provider/bing/create_images.py b/g4f/Provider/bing/create_images.py
index 30fb372d..af39ef1e 100644
--- a/g4f/Provider/bing/create_images.py
+++ b/g4f/Provider/bing/create_images.py
@@ -13,7 +13,7 @@ from urllib.parse import quote
from typing import Generator, List, Dict
from ..create_images import CreateImagesProvider
-from ..helper import get_cookies
+from ..helper import get_cookies, get_connector
from ...webdriver import WebDriver, get_driver_cookies, get_browser
from ...base_provider import ProviderType
from ...image import ImageResponse
@@ -79,13 +79,7 @@ def create_session(cookies: Dict[str, str], proxy: str = None, connector: BaseCo
}
if cookies:
headers["Cookie"] = "; ".join(f"{k}={v}" for k, v in cookies.items())
- 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 ClientSession(headers=headers, connector=connector)
+ return ClientSession(headers=headers, connector=get_connector(connector, proxy))
async def create_images(session: ClientSession, prompt: str, proxy: str = None, timeout: int = TIMEOUT_IMAGE_CREATION) -> List[str]:
"""