summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/BingCreateImages.py
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-04-23 17:34:42 +0200
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-04-23 17:34:42 +0200
commit74c399d675676938f31faf18174a98ed7a1709da (patch)
treed0c06f94dd1c5be203fb02b95e22c51ff976be88 /g4f/Provider/BingCreateImages.py
parentAdd nodriver to docker (diff)
downloadgpt4free-74c399d675676938f31faf18174a98ed7a1709da.tar
gpt4free-74c399d675676938f31faf18174a98ed7a1709da.tar.gz
gpt4free-74c399d675676938f31faf18174a98ed7a1709da.tar.bz2
gpt4free-74c399d675676938f31faf18174a98ed7a1709da.tar.lz
gpt4free-74c399d675676938f31faf18174a98ed7a1709da.tar.xz
gpt4free-74c399d675676938f31faf18174a98ed7a1709da.tar.zst
gpt4free-74c399d675676938f31faf18174a98ed7a1709da.zip
Diffstat (limited to 'g4f/Provider/BingCreateImages.py')
-rw-r--r--g4f/Provider/BingCreateImages.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/g4f/Provider/BingCreateImages.py b/g4f/Provider/BingCreateImages.py
index 69bf1e92..9e5146cc 100644
--- a/g4f/Provider/BingCreateImages.py
+++ b/g4f/Provider/BingCreateImages.py
@@ -19,9 +19,13 @@ class BingCreateImages(AsyncGeneratorProvider, ProviderModelMixin):
needs_auth = True
image_models = ["dall-e"]
- def __init__(self, cookies: Cookies = None, proxy: str = None) -> None:
- self.cookies: Cookies = cookies
- self.proxy: str = proxy
+ def __init__(self, cookies: Cookies = None, proxy: str = None, api_key: str = None) -> None:
+ if api_key is not None:
+ if cookies is None:
+ cookies = {}
+ cookies["_U"] = api_key
+ self.cookies = cookies
+ self.proxy = proxy
@classmethod
async def create_async_generator(
@@ -33,9 +37,7 @@ class BingCreateImages(AsyncGeneratorProvider, ProviderModelMixin):
proxy: str = None,
**kwargs
) -> AsyncResult:
- if api_key is not None:
- cookies = {"_U": api_key}
- session = BingCreateImages(cookies, proxy)
+ session = BingCreateImages(cookies, proxy, api_key)
yield await session.create_async(messages[-1]["content"])
def create(self, prompt: str) -> Iterator[Union[ImageResponse, str]]: