Skip to content

Commit

Permalink
Implement lazy_load() for OutlookMessageLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
cbornet committed Mar 6, 2024
1 parent 81985b3 commit 6820d31
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions libs/community/langchain_community/document_loaders/email.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from typing import Any, List
from typing import Any, Iterator, List

from langchain_core.documents import Document

Expand Down Expand Up @@ -99,13 +99,11 @@ def __init__(self, file_path: str):
"`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,
Expand All @@ -114,4 +112,3 @@ def load(self) -> List[Document]:
"date": msg.date,
},
)
]

0 comments on commit 6820d31

Please sign in to comment.