The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
community[minor]: Implement lazy_load() for FacebookChatLoader (#18669)
Christophe Bornet623dfcc55c7e
diff --git a/libs/community/langchain_community/document_loaders/facebook_chat.py b/libs/community/langchain_community/document_loaders/facebook_chat.pyindex 759499b25e..1122b460c9 100644--- a/libs/community/langchain_community/document_loaders/facebook_chat.py+++ b/libs/community/langchain_community/document_loaders/facebook_chat.py@@ -1,7 +1,7 @@import datetimeimport jsonfrom pathlib import Path-from typing import List+from typing import Iteratorfrom 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)