Skip to main content

GithubToolkit

A class representing a toolkit for interacting with GitHub repositories. This class provides methods for retrieving open issues, retrieving specific issues, and creating pull requests in a GitHub repository. Parameters:
  • access_token (str, optional): The access token to authenticate with GitHub. If not provided, it will be obtained using the get_github_access_token method.

init

Initializes a new instance of the GitHubToolkit class. Parameters:
  • repo_name (str): The name of the GitHub repository.
  • access_token (str, optional): The access token to authenticate with GitHub. If not provided, it will be obtained using the get_github_access_token method.

get_github_access_token

Returns: str: A string containing the GitHub access token.

github_create_pull_request

Creates a pull request. This function creates a pull request in specified repository, which updates a file in the specific path with new content. The pull request description contains information about the issue title and number. Parameters:
  • repo_name (str): The name of the GitHub repository.
  • file_path (str): The path of the file to be updated in the repository.
  • new_content (str): The specified new content of the specified file.
  • pr_title (str): The title of the issue that is solved by this pull request.
  • body (str): The commit message for the pull request.
  • branch_name (str): The name of the branch to create and submit the pull request from.
Returns: str: A formatted report of whether the pull request was created successfully or not.

github_get_issue_list

Retrieves all issues from the GitHub repository. Parameters:
  • repo_name (str): The name of the GitHub repository.
  • state (Literal["open", "closed", "all"]): The state of pull requests to retrieve. (default: :obj:all) Options are: - “open”: Retrieve only open pull requests. - “closed”: Retrieve only closed pull requests. - “all”: Retrieve all pull requests, regardless of state.
Returns: List[Dict[str, object]]: A list of dictionaries where each dictionary contains the issue number and title.

github_get_issue_content

Retrieves the content of a specific issue by its number. Parameters:
  • repo_name (str): The name of the GitHub repository.
  • issue_number (int): The number of the issue to retrieve.
Returns: str: issues content details.

github_get_pull_request_list

Retrieves all pull requests from the GitHub repository. Parameters:
  • repo_name (str): The name of the GitHub repository.
  • state (Literal["open", "closed", "all"]): The state of pull requests to retrieve. (default: :obj:all) Options are: - “open”: Retrieve only open pull requests. - “closed”: Retrieve only closed pull requests. - “all”: Retrieve all pull requests, regardless of state.
Returns: list: A list of dictionaries where each dictionary contains the pull request number and title.

github_get_pull_request_code

Retrieves the code changes of a specific pull request. Parameters:
  • repo_name (str): The name of the GitHub repository.
  • pr_number (int): The number of the pull request to retrieve.
Returns: List[Dict[str, str]]: A list of dictionaries where each dictionary contains the file name and the corresponding code changes (patch).

github_get_pull_request_comments

Retrieves the comments from a specific pull request. Parameters:
  • repo_name (str): The name of the GitHub repository.
  • pr_number (int): The number of the pull request to retrieve.
Returns: List[Dict[str, str]]: A list of dictionaries where each dictionary contains the user ID and the comment body.

github_get_all_file_paths

Recursively retrieves all file paths in the GitHub repository. Parameters:
  • repo_name (str): The name of the GitHub repository.
  • path (str): The repository path to start the traversal from. empty string means starts from the root directory. (default: :obj:"")
Returns: List[str]: A list of file paths within the specified directory structure.

github_retrieve_file_content

Retrieves the content of a file from the GitHub repository. Parameters:
  • repo_name (str): The name of the GitHub repository.
  • file_path (str): The path of the file to retrieve.
Returns: str: The decoded content of the file.

get_tools

Returns: List[FunctionTool]: A list of FunctionTool objects representing the functions in the toolkit.

create_pull_request

Deprecated: Use github_create_pull_request instead.

get_issue_list

Deprecated: Use github_get_issue_list instead.

get_issue_content

Deprecated: Use github_get_issue_content instead.

get_pull_request_list

Deprecated: Use github_get_pull_request_list instead.

get_pull_request_code

Deprecated: Use github_get_pull_request_code instead.

get_pull_request_comments

Deprecated: Use github_get_pull_request_comments instead.

get_all_file_paths

Deprecated: Use github_get_all_file_paths instead.

retrieve_file_content

Deprecated: Use github_retrieve_file_content instead.