mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-23 15:19:33 +00:00
community[minor]: Implement lazy_load() for FacebookChatLoader (#18669)
Integration test: `tests/integration_tests/document_loaders/test_facebook_chat.py`
This commit is contained in:
parent
20794bb889
commit
623dfcc55c
@ -1,7 +1,7 @@
|
||||
import datetime
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
from typing import Iterator
|
||||
|
||||
from langchain_core.documents import Document
|
||||
|
||||
@ -29,8 +29,7 @@ class FacebookChatLoader(BaseLoader):
|
||||
"""Initialize with a path."""
|
||||
self.file_path = path
|
||||
|
||||
def load(self) -> List[Document]:
|
||||
"""Load documents."""
|
||||
def lazy_load(self) -> Iterator[Document]:
|
||||
p = Path(self.file_path)
|
||||
|
||||
with open(p, encoding="utf8") as f:
|
||||
@ -43,4 +42,4 @@ class FacebookChatLoader(BaseLoader):
|
||||
)
|
||||
metadata = {"source": str(p)}
|
||||
|
||||
return [Document(page_content=text, metadata=metadata)]
|
||||
yield Document(page_content=text, metadata=metadata)
|
||||
|
Loading…
Reference in New Issue
Block a user