mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-19 13:23:35 +00:00
community[minor]: Implement lazy_load() for OutlookMessageLoader (#18668)
Integration test: `tests/integration_tests/document_loaders/test_email.py`
This commit is contained in:
parent
ae167fb5b2
commit
2d96803ddd
@ -1,5 +1,5 @@
|
||||
import os
|
||||
from typing import Any, List
|
||||
from typing import Any, Iterator, List
|
||||
|
||||
from langchain_core.documents import Document
|
||||
|
||||
@ -99,13 +99,11 @@ class OutlookMessageLoader(BaseLoader):
|
||||
"`pip install extract_msg`"
|
||||
)
|
||||
|
||||
def load(self) -> List[Document]:
|
||||
"""Load data into document objects."""
|
||||
def lazy_load(self) -> Iterator[Document]:
|
||||
import extract_msg
|
||||
|
||||
msg = extract_msg.Message(self.file_path)
|
||||
return [
|
||||
Document(
|
||||
yield Document(
|
||||
page_content=msg.body,
|
||||
metadata={
|
||||
"source": self.file_path,
|
||||
@ -114,4 +112,3 @@ class OutlookMessageLoader(BaseLoader):
|
||||
"date": msg.date,
|
||||
},
|
||||
)
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user