Skip to content

Commit

Permalink
fix: inline
Browse files Browse the repository at this point in the history
  • Loading branch information
himself65 committed Mar 7, 2025
1 parent 721f533 commit 1a4d21a
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import base64
import os

import filetype
import logging
from typing import List, Optional, Sequence
Expand Down Expand Up @@ -57,13 +59,14 @@ def image_documents_to_base64(
for image_document in image_documents:
if image_document.image: # This field is already base64-encoded
image_encodings.append(image_document.image)
elif (
elif image_document.image_path and os.path.isfile(
image_document.image_path
): # This field is a path to the image, which is then encoded.
image_encodings.append(encode_image(image_document.image_path))
elif (
"file_path" in image_document.metadata
and image_document.metadata["file_path"] != ""
and os.path.isfile(image_document.metadata["file_path"])
): # Alternative path to the image, which is then encoded.
image_encodings.append(encode_image(image_document.metadata["file_path"]))
elif image_document.image_url: # Image can also be pulled from the URL.
Expand Down

0 comments on commit 1a4d21a

Please sign in to comment.