summaryrefslogtreecommitdiffstats
path: root/g4f/image.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-04-21 07:45:23 +0200
committerGitHub <noreply@github.com>2024-04-21 07:45:23 +0200
commit0f3935f1c068c723342153dd040e0e72e95aa11b (patch)
treec4d1e9c9eb2ebfe13e2679afe8a23d7ffa45fa46 /g4f/image.py
parentMerge pull request #1865 from hlohaus/carst (diff)
parentAdd MissingRequirementsError to You (diff)
downloadgpt4free-0f3935f1c068c723342153dd040e0e72e95aa11b.tar
gpt4free-0f3935f1c068c723342153dd040e0e72e95aa11b.tar.gz
gpt4free-0f3935f1c068c723342153dd040e0e72e95aa11b.tar.bz2
gpt4free-0f3935f1c068c723342153dd040e0e72e95aa11b.tar.lz
gpt4free-0f3935f1c068c723342153dd040e0e72e95aa11b.tar.xz
gpt4free-0f3935f1c068c723342153dd040e0e72e95aa11b.tar.zst
gpt4free-0f3935f1c068c723342153dd040e0e72e95aa11b.zip
Diffstat (limited to 'g4f/image.py')
-rw-r--r--g4f/image.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/g4f/image.py b/g4f/image.py
index 5402f9c8..ed8af103 100644
--- a/g4f/image.py
+++ b/g4f/image.py
@@ -210,7 +210,9 @@ def format_images_markdown(images: Union[str, list], alt: str, preview: Union[st
if not isinstance(preview, list):
preview = [preview.replace('{image}', image) if preview else image for image in images]
result = "\n".join(
- f"[![#{idx+1} {alt}]({preview[idx]})]({image})" for idx, image in enumerate(images)
+ #f"[![#{idx+1} {alt}]({preview[idx]})]({image})"
+ f'[<img src="{preview[idx]}" width="200" alt="#{idx+1} {alt}">]({image})'
+ for idx, image in enumerate(images)
)
start_flag = "<!-- generated images start -->\n"
end_flag = "<!-- generated images end -->\n"
@@ -259,6 +261,13 @@ class ImageResponse:
def get_list(self) -> list[str]:
return [self.images] if isinstance(self.images, str) else self.images
+class ImagePreview(ImageResponse):
+ def __str__(self):
+ return ""
+
+ def to_string(self):
+ return super().__str__()
+
class ImageRequest:
def __init__(
self,