mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-09 21:08:59 +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 ""
|
return ""
|
||||||
|
|
||||||
def load(self) -> List[Document]:
|
def lazy_load(self) -> Iterator[Document]:
|
||||||
documents = []
|
|
||||||
|
|
||||||
files = self.get_file_paths()
|
files = self.get_file_paths()
|
||||||
for file in files:
|
for file in files:
|
||||||
content = self.get_file_content_by_path(file["path"])
|
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']}/"
|
"source": f"{self.github_api_url}/{self.repo}/{file['type']}/"
|
||||||
f"{self.branch}/{file['path']}",
|
f"{self.branch}/{file['path']}",
|
||||||
}
|
}
|
||||||
documents.append(Document(page_content=content, metadata=metadata))
|
yield Document(page_content=content, metadata=metadata)
|
||||||
|
|
||||||
return documents
|
|
||||||
|
Loading…
Reference in New Issue
Block a user