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
fixed_max_resultsintNoneOptional fixed maximum number of results to return.
fixed_languagestrNoneOptional fixed language for the requests.
headersAnyNoneOptional headers to include in the requests.
proxystrNoneOptional proxy to be used for the requests.
timeoutintNoneOptional timeout for the requests, in seconds.

Toolkit Functions

FunctionDescription
google_searchSearches Google for a specified query. Parameters include:
- query: the search term
- max_results: maximum number of results (default is 5)
- language: language of the search results (default is “en”)
Returns the search results as a JSON formatted string.