summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/bing
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-01-29 18:14:46 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-01-29 18:14:46 +0100
commita28bab938704a15c825c1b45a8983c72e8c90ace (patch)
tree0a3ee26bb1f9e7bf7c1a5a739ed59015248acbfb /g4f/Provider/bing
parentMerge pull request #1523 from u66u/which-webdriver (diff)
downloadgpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.tar
gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.tar.gz
gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.tar.bz2
gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.tar.lz
gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.tar.xz
gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.tar.zst
gpt4free-a28bab938704a15c825c1b45a8983c72e8c90ace.zip
Diffstat (limited to 'g4f/Provider/bing')
-rw-r--r--g4f/Provider/bing/create_images.py9
-rw-r--r--g4f/Provider/bing/upload_image.py2
2 files changed, 5 insertions, 6 deletions
diff --git a/g4f/Provider/bing/create_images.py b/g4f/Provider/bing/create_images.py
index a3fcd91b..e1031e61 100644
--- a/g4f/Provider/bing/create_images.py
+++ b/g4f/Provider/bing/create_images.py
@@ -187,11 +187,11 @@ def get_cookies_from_browser(proxy: str = None) -> dict[str, str]:
class CreateImagesBing:
"""A class for creating images using Bing."""
-
+
def __init__(self, cookies: dict[str, str] = {}, proxy: str = None) -> None:
self.cookies = cookies
self.proxy = proxy
-
+
def create_completion(self, prompt: str) -> Generator[ImageResponse, None, None]:
"""
Generator for creating imagecompletion based on a prompt.
@@ -229,9 +229,7 @@ class CreateImagesBing:
proxy = os.environ.get("G4F_PROXY")
async with create_session(cookies, proxy) as session:
images = await create_images(session, prompt, self.proxy)
- return ImageResponse(images, prompt)
-
-service = CreateImagesBing()
+ return ImageResponse(images, prompt, {"preview": "{image}?w=200&h=200"})
def patch_provider(provider: ProviderType) -> CreateImagesProvider:
"""
@@ -243,6 +241,7 @@ def patch_provider(provider: ProviderType) -> CreateImagesProvider:
Returns:
CreateImagesProvider: The patched provider with image creation capabilities.
"""
+ service = CreateImagesBing()
return CreateImagesProvider(
provider,
service.create_completion,
diff --git a/g4f/Provider/bing/upload_image.py b/g4f/Provider/bing/upload_image.py
index f9e11561..6d51aba0 100644
--- a/g4f/Provider/bing/upload_image.py
+++ b/g4f/Provider/bing/upload_image.py
@@ -149,4 +149,4 @@ def parse_image_response(response: dict) -> ImageRequest:
if IMAGE_CONFIG["enableFaceBlurDebug"] else
f"https://www.bing.com/images/blob?bcid={result['bcid']}"
)
- return ImageRequest(result["imageUrl"], "", result) \ No newline at end of file
+ return ImageRequest(result) \ No newline at end of file