Skip to content

Commit

Permalink
Display generated images inline.
Browse files Browse the repository at this point in the history
  • Loading branch information
EtiennePerot committed Oct 12, 2024
1 parent fae5797 commit 17ae258
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions open-webui/functions/run_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@ def _inline_markdown(self):
"""Render the file as inline text or markdown if small enough; otherwise return None."""
if self._size_bytes > self.MAX_INLINE_TEXT_BYTES:
return None
if self._mime_type.startswith("image/"):
return f"\U0001f5bc [{self.name}]({self.url}): \n![{self.name}]({self.url})"
if not self._mime_type.startswith("text/"):
return None
with open(self._file_path, "rb") as f:
Expand Down
2 changes: 2 additions & 0 deletions src/openwebui/functions/run_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ def _inline_markdown(self):
"""Render the file as inline text or markdown if small enough; otherwise return None."""
if self._size_bytes > self.MAX_INLINE_TEXT_BYTES:
return None
if self._mime_type.startswith("image/"):
return f"\U0001f5bc [{self.name}]({self.url}): \n![{self.name}]({self.url})"
if not self._mime_type.startswith("text/"):
return None
with open(self._file_path, "rb") as f:
Expand Down

0 comments on commit 17ae258

Please sign in to comment.