diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-05-18 23:18:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-18 23:18:32 +0200 |
commit | 97ce36a217b7998aee460c62c926c0c1f6f3baf6 (patch) | |
tree | 4a137ca4958a81272e37f952b9330a197038f83f /g4f/Provider/bing | |
parent | Merge pull request #1974 from hlohaus/leech (diff) | |
parent | Add get/set cookies dir, hide prompt option in gui (diff) | |
download | gpt4free-97ce36a217b7998aee460c62c926c0c1f6f3baf6.tar gpt4free-97ce36a217b7998aee460c62c926c0c1f6f3baf6.tar.gz gpt4free-97ce36a217b7998aee460c62c926c0c1f6f3baf6.tar.bz2 gpt4free-97ce36a217b7998aee460c62c926c0c1f6f3baf6.tar.lz gpt4free-97ce36a217b7998aee460c62c926c0c1f6f3baf6.tar.xz gpt4free-97ce36a217b7998aee460c62c926c0c1f6f3baf6.tar.zst gpt4free-97ce36a217b7998aee460c62c926c0c1f6f3baf6.zip |
Diffstat (limited to 'g4f/Provider/bing')
-rw-r--r-- | g4f/Provider/bing/create_images.py | 30 |
1 files changed, 3 insertions, 27 deletions
diff --git a/g4f/Provider/bing/create_images.py b/g4f/Provider/bing/create_images.py index 44303c21..7a08ddfe 100644 --- a/g4f/Provider/bing/create_images.py +++ b/g4f/Provider/bing/create_images.py @@ -1,7 +1,3 @@ -""" -This module provides functionalities for creating and managing images using Bing's service. -It includes functions for user login, session creation, image creation, and processing. -""" from __future__ import annotations import asyncio @@ -17,9 +13,7 @@ try: except ImportError: has_requirements = False -from ...providers.create_images import CreateImagesProvider from ..helper import get_connector -from ...providers.types import ProviderType from ...errors import MissingRequirementsError, RateLimitError from ...webdriver import WebDriver, get_driver_cookies, get_browser @@ -101,7 +95,7 @@ def create_session(cookies: Dict[str, str], proxy: str = None, connector: BaseCo headers["Cookie"] = "; ".join(f"{k}={v}" for k, v in cookies.items()) 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]: +async def create_images(session: ClientSession, prompt: str, timeout: int = TIMEOUT_IMAGE_CREATION) -> List[str]: """ Creates images based on a given prompt using Bing's service. @@ -132,7 +126,7 @@ async def create_images(session: ClientSession, prompt: str, proxy: str = None, raise RuntimeError(f"Create images failed: {error}") if response.status != 302: url = f"{BING_URL}/images/create?q={url_encoded_prompt}&rt=3&FORM=GENCRE" - async with session.post(url, allow_redirects=False, proxy=proxy, timeout=timeout) as response: + async with session.post(url, allow_redirects=False, timeout=timeout) as response: if response.status != 302: raise RuntimeError(f"Create images failed. Code: {response.status}") @@ -185,22 +179,4 @@ def read_images(html_content: str) -> List[str]: raise RuntimeError("Bad images found") if not images: raise RuntimeError("No images found") - return images - -def patch_provider(provider: ProviderType) -> CreateImagesProvider: - """ - Patches a provider to include image creation capabilities. - - Args: - provider (ProviderType): The provider to be patched. - - Returns: - CreateImagesProvider: The patched provider with image creation capabilities. - """ - from ..BingCreateImages import BingCreateImages - service = BingCreateImages() - return CreateImagesProvider( - provider, - service.create, - service.create_async - )
\ No newline at end of file + return images
\ No newline at end of file |