mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-30 08:14:47 +00:00
community: Implement lazy_load() for WhatsAppChatLoader (#18677)
Integration test: `tests/integration_tests/document_loaders/test_whatsapp_chat.py`
This commit is contained in:
parent
f414f5cdb9
commit
ed36f9f604
@ -1,6 +1,6 @@
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
from typing import Iterator
|
||||
|
||||
from langchain_core.documents import Document
|
||||
|
||||
@ -19,8 +19,7 @@ class WhatsAppChatLoader(BaseLoader):
|
||||
"""Initialize with path."""
|
||||
self.file_path = path
|
||||
|
||||
def load(self) -> List[Document]:
|
||||
"""Load documents."""
|
||||
def lazy_load(self) -> Iterator[Document]:
|
||||
p = Path(self.file_path)
|
||||
text_content = ""
|
||||
|
||||
@ -62,4 +61,4 @@ class WhatsAppChatLoader(BaseLoader):
|
||||
|
||||
metadata = {"source": str(p)}
|
||||
|
||||
return [Document(page_content=text_content, metadata=metadata)]
|
||||
yield Document(page_content=text_content, metadata=metadata)
|
||||
|
Loading…
Reference in New Issue
Block a user