GithubTools enables an Agent to access Github repositories and perform tasks such as listing open pull requests, issues and more.

Prerequisites

The following examples requires the PyGithub library and a Github access token which can be obtained from here.

pip install -U PyGithub
export GITHUB_ACCESS_TOKEN=***

Example

The following agent will search Google for the latest news about “Mistral AI”:

cookbook/tools/github_tools.py
from phi.agent import Agent
from phi.tools.github import GithubTools

agent = Agent(
    instructions=[
        "Use your tools to answer questions about the repo: phidatahq/phidata",
        "Do not create any issues or pull requests unless explicitly asked to do so",
    ],
    tools=[GithubTools()],
    show_tool_calls=True,
)
agent.print_response("List open pull requests", markdown=True)

Toolkit Params

ParameterTypeDefaultDescription
access_tokenstrNoneGithub access token for authentication. If not provided, will use GITHUB_ACCESS_TOKEN environment variable.
base_urlstrNoneOptional base URL for Github Enterprise installations.
search_repositoriesboolTrueEnable searching Github repositories.
list_repositoriesboolTrueEnable listing repositories for a user/organization.
get_repositoryboolTrueEnable getting repository details.
list_pull_requestsboolTrueEnable listing pull requests for a repository.
get_pull_requestboolTrueEnable getting pull request details.
get_pull_request_changesboolTrueEnable getting pull request file changes.
create_issueboolTrueEnable creating issues in repositories.

Toolkit Functions

FunctionDescription
search_repositoriesSearches Github repositories based on a query.
list_repositoriesLists repositories for a given user or organization.
get_repositoryGets details about a specific repository.
list_pull_requestsLists pull requests for a repository.
get_pull_requestGets details about a specific pull request.
get_pull_request_changesGets the file changes in a pull request.
create_issueCreates a new issue in a repository.

Information