summaryrefslogtreecommitdiffstats
path: root/g4f
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-02-12 12:08:08 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-02-12 12:08:08 +0100
commit151f8b8b0e409b112c806927250d5f578f0f6805 (patch)
treeeb9576c91c9494722716a8d20b9f5e436547f7ab /g4f
parentAdd new Client API with Docs (diff)
downloadgpt4free-151f8b8b0e409b112c806927250d5f578f0f6805.tar
gpt4free-151f8b8b0e409b112c806927250d5f578f0f6805.tar.gz
gpt4free-151f8b8b0e409b112c806927250d5f578f0f6805.tar.bz2
gpt4free-151f8b8b0e409b112c806927250d5f578f0f6805.tar.lz
gpt4free-151f8b8b0e409b112c806927250d5f578f0f6805.tar.xz
gpt4free-151f8b8b0e409b112c806927250d5f578f0f6805.tar.zst
gpt4free-151f8b8b0e409b112c806927250d5f578f0f6805.zip
Diffstat (limited to 'g4f')
-rw-r--r--g4f/client.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/g4f/client.py b/g4f/client.py
index 117db375..03b0eda3 100644
--- a/g4f/client.py
+++ b/g4f/client.py
@@ -241,7 +241,8 @@ class Images():
"",
[{"role": "user", "content": prompt}],
True,
- proxy=self.client.get_proxy()
+ proxy=self.client.get_proxy(),
+ **kwargs
)
else:
response = provider.create(prompt)
@@ -253,15 +254,20 @@ class Images():
def create_variation(self, image: ImageType, model: str = None, **kwargs):
provider = self.models.get(model) if model else self.provider
- if isinstance(provider, BaseProvider):
+ result = None
+ if isinstance(provider, type) and issubclass(provider, BaseProvider):
response = provider.create_completion(
"",
[{"role": "user", "content": "create a image like this"}],
True,
image=image,
- proxy=self.client.get_proxy()
+ proxy=self.client.get_proxy(),
+ **kwargs
)
for chunk in response:
if isinstance(chunk, ImageProviderResponse):
- return ImagesResponse([Image(image)for image in list(chunk.images)])
- raise NoImageResponseError() \ No newline at end of file
+ result = ([chunk.images] if isinstance(chunk.images, str) else chunk.images)
+ result = ImagesResponse([Image(image)for image in result])
+ if result is None:
+ raise NoImageResponseError()
+ return result \ No newline at end of file