Merge pull request #18656

* Implement lazy_load() for PsychicLoader
pull/18603/head
Christophe Bornet 4 months ago committed by GitHub
parent aa7ac57b67
commit b9c0cf9025
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Iterator, Optional
from langchain_core.documents import Document
@ -29,16 +29,12 @@ class PsychicLoader(BaseLoader):
self.connector_id = ConnectorId(connector_id)
self.account_id = account_id
def load(self) -> List[Document]:
"""Load documents."""
def lazy_load(self) -> Iterator[Document]:
psychic_docs = self.psychic.get_documents(
connector_id=self.connector_id, account_id=self.account_id
)
return [
Document(
for doc in psychic_docs.documents:
yield Document(
page_content=doc["content"],
metadata={"title": doc["title"], "source": doc["uri"]},
)
for doc in psychic_docs.documents
]

Loading…
Cancel
Save