mirror of
https://github.com/Mintplex-Labs/langchain-python.git
synced 2026-07-19 13:26:32 -04:00
270384fb44
### Summary #1667 updated several Unstructured loaders to accept `unstructured_kwargs` in the `__init__` function. However, the previous PR did not add this functionality to every Unstructured loader. This PR ensures `unstructured_kwargs` are passed in all remaining Unstructured loaders.
23 lines
775 B
Python
23 lines
775 B
Python
"""Loader that loads EPub files."""
|
|
from typing import List
|
|
|
|
from langchain.document_loaders.unstructured import (
|
|
UnstructuredFileLoader,
|
|
satisfies_min_unstructured_version,
|
|
)
|
|
|
|
|
|
class UnstructuredEPubLoader(UnstructuredFileLoader):
|
|
"""Loader that uses unstructured to load epub files."""
|
|
|
|
def _get_elements(self) -> List:
|
|
min_unstructured_version = "0.5.4"
|
|
if not satisfies_min_unstructured_version(min_unstructured_version):
|
|
raise ValueError(
|
|
"Partitioning epub files is only supported in "
|
|
f"unstructured>={min_unstructured_version}."
|
|
)
|
|
from unstructured.partition.epub import partition_epub
|
|
|
|
return partition_epub(filename=self.file_path, **self.unstructured_kwargs)
|