Skip to content

Commit

Permalink
warn not embedded images individually
Browse files Browse the repository at this point in the history
  • Loading branch information
kdziedzic68 committed Nov 28, 2024
1 parent e11c079 commit 76ebf08
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ async def insert_elements(self, elements: list[Element]) -> None:
element.to_vector_db_entry(vector, EmbeddingTypes.TEXT)
for element, vector in zip(elements_with_text, vectors, strict=False)
]
num_embedded_images = len(images_with_text)
not_embedded_image_elements = [
image_element for image_element in image_elements if image_element not in images_with_text
]

if image_elements and self.embedder.image_support():
image_vectors = await self.embedder.embed_image([element.image_bytes for element in image_elements])
Expand All @@ -177,16 +179,14 @@ async def insert_elements(self, elements: list[Element]) -> None:
for element, vector in zip(image_elements, image_vectors, strict=False)
]
)
num_embedded_images = len(image_elements)
not_embedded_image_elements = []
elif image_elements:
warnings.warn(
f"Image elements are not supported by the embedder {self.embedder}. "
f"Skipping {len(image_elements)} image elements."
)

if len(image_elements) > num_embedded_images:
warnings.warn(
f"{len(image_elements) - num_embedded_images} of {len(image_elements)} have not been embedded"
)
for image_element in not_embedded_image_elements:
warnings.warn(f"Image: {image_element.id} could not be embedded")

await self.vector_store.store(entries)

0 comments on commit 76ebf08

Please sign in to comment.