Skip to content

Github repo tools

AUTO_SHOW_NODE_IDS_THRESHOLD = 100 module-attribute

logger = logging.getLogger(__name__) module-attribute

GithubRepoGetFileTool

Bases: BaseTool

args_schema = RepoFileArgs class-attribute instance-attribute

description = 'Get the contents of a specific file in a repository.' class-attribute instance-attribute

github_adapter instance-attribute

name = ToolNames.GITHUB_REPO_GET_FILE class-attribute instance-attribute

response_format = 'content_and_artifact' class-attribute instance-attribute

tags = Field(default=['github_repo_get_file']) class-attribute instance-attribute

GithubRepoGetFilesTool

Bases: BaseTool

args_schema = RepoFilesArgs class-attribute instance-attribute

description = 'Get the contents of multiple files in a repository (requires node_ids that can be obtained from repo structure tool).' class-attribute instance-attribute

github_adapter instance-attribute

name = ToolNames.GITHUB_REPO_GET_FILES class-attribute instance-attribute

response_format = 'content_and_artifact' class-attribute instance-attribute

tags = Field(default_factory=lambda: ['github_repo_get_files']) class-attribute instance-attribute

GithubRepoListOwnerRepos

Bases: BaseTool

args_schema = ListOwnerRepoArgs class-attribute instance-attribute

description = 'List the repositories of a specific owner (user or organization).' class-attribute instance-attribute

github_adapter instance-attribute

name = ToolNames.GITHUB_REPO_LIST_OWNER_REPOS class-attribute instance-attribute

response_format = 'content_and_artifact' class-attribute instance-attribute

tags = Field(default=['github_repo_list_owner_repos']) class-attribute instance-attribute

GithubRepoListRepoBranches

Bases: BaseTool

args_schema = ListRepoBranchesArgs class-attribute instance-attribute

description = 'List the branches of a specific repository.' class-attribute instance-attribute

github_adapter instance-attribute

name = ToolNames.GITHUB_REPO_LIST_REPO_BRANCHES class-attribute instance-attribute

response_format = 'content_and_artifact' class-attribute instance-attribute

tags = Field(default=['github_repo_list_repo_branches']) class-attribute instance-attribute

GithubRepoStructureTool

Bases: BaseTool

args_schema = RepoStructureArgs class-attribute instance-attribute

description = 'Search for specific code/text snippets within a repository.' class-attribute instance-attribute

github_adapter instance-attribute

name = ToolNames.GITHUB_REPO_STRUCTURE class-attribute instance-attribute

response_format = 'content_and_artifact' class-attribute instance-attribute

tags = Field(default=['github_repo_structure']) class-attribute instance-attribute

ListOwnerRepoArgs

Bases: BaseModel

Args for listing repositories of a specific owner.

Note: Doesn't require full RepoID so it's a separate class.

repo_owner = Field(description='The owner (or organization) of the repository.') class-attribute instance-attribute

user_id instance-attribute

ListRepoBranchesArgs

Bases: RepoIDArgs

Extend RepoIDArgs for listing branches of a repository.

RepoFileArgs

Bases: RepoIDArgs

Extend RepoIDArgs for getting a specific file.

file_path = Field(description='The path to the file to get.') class-attribute instance-attribute

RepoFilesArgs

Bases: RepoIDArgs

Extend RepoIDArgs for getting multiple files.

node_ids = Field(description='The node_ids of the files to get.') class-attribute instance-attribute

RepoIDArgs

Bases: BaseModel

Args common to all GitHub repo tools.

repo_branch = Field(default='main', description='The branch of the repository (e.g. `master`, `feature-x`)') class-attribute instance-attribute

repo_name = Field(description='The name of the repository.') class-attribute instance-attribute

repo_owner = Field(description='The owner (or organization) of the repository.') class-attribute instance-attribute

user_id instance-attribute

RepoStructureArgs

Bases: RepoIDArgs

Extend RepoIDArgs for getting repo structure.

depth = Field(default=None, description='The max depth of directories to look in. E.g., None goes to max depth, 1 returns only files/directory names in root of repo.', ge=1) class-attribute instance-attribute

show_node_ids = Field(default=None, description="Whether to also include node_id along with each file/blob in the output. (default shows node_idsif there aren't too many results.)") class-attribute instance-attribute

blob_to_content(blob)

Convert a FullBlob to a readable string representation of its content.

I.e., Show the content of the blob (file)

full_blobs_to_content(full_blobs)

tree_to_content(tree, size_threshold=None, show_node_ids=False)

Convert a Tree to a readable string representation of its content.

Displays file structure of the tree with indentation for each subtree (directory) and file sizes for blobs (files).