mirror of
https://github.com/hwchase17/langchain
synced 2024-10-31 15:20:26 +00:00
parent
5b92f962f1
commit
68fc0cf909
@ -1,5 +1,5 @@
|
||||
import logging
|
||||
from typing import List, Optional
|
||||
from typing import Iterator, Optional
|
||||
|
||||
from langchain_core.documents import Document
|
||||
|
||||
@ -34,7 +34,7 @@ class TextLoader(BaseLoader):
|
||||
self.encoding = encoding
|
||||
self.autodetect_encoding = autodetect_encoding
|
||||
|
||||
def load(self) -> List[Document]:
|
||||
def lazy_load(self) -> Iterator[Document]:
|
||||
"""Load from file path."""
|
||||
text = ""
|
||||
try:
|
||||
@ -57,4 +57,4 @@ class TextLoader(BaseLoader):
|
||||
raise RuntimeError(f"Error loading {self.file_path}") from e
|
||||
|
||||
metadata = {"source": self.file_path}
|
||||
return [Document(page_content=text, metadata=metadata)]
|
||||
yield Document(page_content=text, metadata=metadata)
|
||||
|
Loading…
Reference in New Issue
Block a user