summaryrefslogtreecommitdiffstats
path: root/g4f/gui/server/api.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/gui/server/api.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/gui/server/api.py')
-rw-r--r--g4f/gui/server/api.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/g4f/gui/server/api.py b/g4f/gui/server/api.py
index 211d40c6..47c25eb7 100644
--- a/g4f/gui/server/api.py
+++ b/g4f/gui/server/api.py
@@ -7,6 +7,7 @@ from typing import Iterator
from g4f import version, models
from g4f import get_last_provider, ChatCompletion
from g4f.errors import VersionNotFoundError
+from g4f.image import ImagePreview
from g4f.Provider import ProviderType, __providers__, __map__
from g4f.providers.base_provider import ProviderModelMixin, FinishReason
from g4f.providers.conversation import BaseConversation
@@ -146,6 +147,8 @@ class Api():
elif isinstance(chunk, Exception):
logging.exception(chunk)
yield self._format_json("message", get_error_message(chunk))
+ elif isinstance(chunk, ImagePreview):
+ yield self._format_json("preview", chunk.to_string())
elif not isinstance(chunk, FinishReason):
yield self._format_json("content", str(chunk))
except Exception as e: