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