Skip to content

The agent engineering platform.

community: correct return type of get_files_from_directory in github tool (#27885)

Lorenzob79a1156eda6
diff --git a/libs/community/langchain_community/utilities/github.py b/libs/community/langchain_community/utilities/github.py
index 56426ca834..2674b749de 100644
--- a/libs/community/langchain_community/utilities/github.py
+++ b/libs/community/langchain_community/utilities/github.py
@@ -213,7 +213,7 @@ class GitHubAPIWrapper(BaseModel):
)
for content in contents:
if content.type == "dir":
- files.extend(self.get_files_from_directory(content.path))
+ files.extend(self._list_files(content.path))
else:
files.append(content.path)
@@ -324,7 +324,7 @@ class GitHubAPIWrapper(BaseModel):
)
for content in contents:
if content.type == "dir":
- files.extend(self.get_files_from_directory(content.path))
+ files.extend(self._list_files(content.path))
else:
files.append(content.path)
@@ -351,20 +351,24 @@ class GitHubAPIWrapper(BaseModel):
"""
from github import GithubException
- files: List[str] = []
try:
- contents = self.github_repo_instance.get_contents(
- directory_path, ref=self.active_branch
- )
+ return str(self._list_files(directory_path))
except GithubException as e:
return f"Error: status code {e.status}, {e.message}"
+ def _list_files(self, directory_path: str) -> List[str]:
+ files: List[str] = []
+
+ contents = self.github_repo_instance.get_contents(
+ directory_path, ref=self.active_branch
+ )
+
for content in contents:
if content.type == "dir":
- files.extend(self.get_files_from_directory(content.path))
+ files.extend(self._list_files(content.path))
else:
files.append(content.path)
- return str(files)
+ return files
def get_issue(self, issue_number: int) -> Dict[str, Any]:
"""