Skip to content

Commit

Permalink
Implement lazy_load() for FacebookChatLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
cbornet committed Mar 6, 2024
1 parent 81985b3 commit 6f28ae6
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -29,7 +29,7 @@ def __init__(self, path: str):
"""Initialize with a path."""
self.file_path = path

def load(self) -> List[Document]:
def lazy_load(self) -> Iterator[Document]:
"""Load documents."""
p = Path(self.file_path)

Expand All @@ -43,4 +43,4 @@ def load(self) -> List[Document]:
)
metadata = {"source": str(p)}

return [Document(page_content=text, metadata=metadata)]
yield Document(page_content=text, metadata=metadata)

0 comments on commit 6f28ae6

Please sign in to comment.