mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-09 04:50:37 +00:00
community: Implement lazy_load() for GithubFileLoader (#18584)
This commit is contained in:
parent
04d134df17
commit
c8a171a154
@ -217,9 +217,7 @@ class GithubFileLoader(BaseGitHubLoader, ABC):
|
||||
|
||||
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"])
|
||||
@ -232,6 +230,4 @@ class GithubFileLoader(BaseGitHubLoader, ABC):
|
||||
"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)
|
||||
|
Loading…
Reference in New Issue
Block a user