core[minor]: Add aload to document loader (#19936)

Add aload to document loader
This commit is contained in:
Eugene Yurtsev
2024-04-03 10:46:47 -04:00
committed by GitHub
parent 31a641a155
commit d293431e10
3 changed files with 6 additions and 1 deletions

View File

@@ -28,6 +28,10 @@ class BaseLoader(ABC):
"""Load data into Document objects."""
return list(self.lazy_load())
async def aload(self) -> List[Document]:
"""Load data into Document objects."""
return [document async for document in self.alazy_load()]
def load_and_split(
self, text_splitter: Optional[TextSplitter] = None
) -> List[Document]:

View File

@@ -64,3 +64,4 @@ async def test_default_aload() -> None:
docs = loader.load()
assert docs == [Document(page_content="foo"), Document(page_content="bar")]
assert docs == [doc async for doc in loader.alazy_load()]
assert docs == await loader.aload()