Skip to content

Commit

Permalink
community: Implement lazy_load() for GithubFileLoader (langchain-ai#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
cbornet authored and thebhulawat committed Mar 6, 2024
1 parent 7165b59 commit 0a61954
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions libs/community/langchain_community/document_loaders/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,7 @@ def get_file_content_by_path(self, path: str) -> str:

return ""

def load(self) -> List[Document]:
documents = []

def lazy_load(self) -> Iterator[Document]:
files = self.get_file_paths()
for file in files:
content = self.get_file_content_by_path(file["path"])
Expand All @@ -232,6 +230,4 @@ def load(self) -> List[Document]:
"source": f"{self.github_api_url}/{self.repo}/{file['type']}/"
f"{self.branch}/{file['path']}",
}
documents.append(Document(page_content=content, metadata=metadata))

return documents
yield Document(page_content=content, metadata=metadata)

0 comments on commit 0a61954

Please sign in to comment.