mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-05 04:55:14 +00:00
langchain[minor],community[minor]: Add async methods in BaseLoader (#16634)
Adds: * methods `aload()` and `alazy_load()` to interface `BaseLoader` * implementation for class `MergedDataLoader ` * support for class `BaseLoader` in async function `aindex()` with unit tests Note: this is compatible with existing `aload()` methods that some loaders already had. **Twitter handle:** @cbornet_ --------- Co-authored-by: Eugene Yurtsev <eugene@langchain.dev>
This commit is contained in:
committed by
GitHub
parent
c37ca45825
commit
af8c5c185b
@@ -1,4 +1,4 @@
|
||||
from typing import Iterator, List
|
||||
from typing import AsyncIterator, Iterator, List
|
||||
|
||||
from langchain_core.documents import Document
|
||||
|
||||
@@ -26,3 +26,9 @@ class MergedDataLoader(BaseLoader):
|
||||
def load(self) -> List[Document]:
|
||||
"""Load docs."""
|
||||
return list(self.lazy_load())
|
||||
|
||||
async def alazy_load(self) -> AsyncIterator[Document]:
|
||||
"""Lazy load docs from each individual loader."""
|
||||
for loader in self.loaders:
|
||||
async for document in loader.alazy_load():
|
||||
yield document
|
||||
|
Reference in New Issue
Block a user