summaryrefslogtreecommitdiffstats
path: root/g4f/providers/create_images.py
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-03-13 05:27:54 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-03-13 05:27:54 +0100
commitecf110e59a35ad41377b82d8d1f5f58802b66539 (patch)
treec3d9da4d4305c14fe01b3fcd77af161b7fb2a9cb /g4f/providers/create_images.py
parentAdd count chars to gui, Add retry support to fix rate limit in Bing (diff)
downloadgpt4free-ecf110e59a35ad41377b82d8d1f5f58802b66539.tar
gpt4free-ecf110e59a35ad41377b82d8d1f5f58802b66539.tar.gz
gpt4free-ecf110e59a35ad41377b82d8d1f5f58802b66539.tar.bz2
gpt4free-ecf110e59a35ad41377b82d8d1f5f58802b66539.tar.lz
gpt4free-ecf110e59a35ad41377b82d8d1f5f58802b66539.tar.xz
gpt4free-ecf110e59a35ad41377b82d8d1f5f58802b66539.tar.zst
gpt4free-ecf110e59a35ad41377b82d8d1f5f58802b66539.zip
Diffstat (limited to '')
-rw-r--r--g4f/providers/create_images.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/g4f/providers/create_images.py b/g4f/providers/create_images.py
index 29a2a041..29db9435 100644
--- a/g4f/providers/create_images.py
+++ b/g4f/providers/create_images.py
@@ -6,6 +6,7 @@ import asyncio
from .. import debug
from ..typing import CreateResult, Messages
from .types import BaseProvider, ProviderType
+from ..image import ImageResponse
system_message = """
You can generate images, pictures, photos or img with the DALL-E 3 image generator.
@@ -92,7 +93,9 @@ class CreateImagesProvider(BaseProvider):
messages.insert(0, {"role": "system", "content": self.system_message})
buffer = ""
for chunk in self.provider.create_completion(model, messages, stream, **kwargs):
- if isinstance(chunk, str) and buffer or "<" in chunk:
+ if isinstance(chunk, ImageResponse):
+ yield chunk
+ elif isinstance(chunk, str) and buffer or "<" in chunk:
buffer += chunk
if ">" in buffer:
match = re.search(r'<img data-prompt="(.*?)">', buffer)