---
title: Github
---

**GithubTools** 使 Agent 能够访问 Github 仓库并执行诸如列出打开的拉取请求、问题等任务。

## 先决条件

以下示例需要 `PyGithub` 库和 Github 访问令牌,可以从 [此处](https://github.com/settings/tokens) 获取。

```shell
pip install -U PyGithub
export GITHUB_ACCESS_TOKEN=***

示例

以下 Agent 将在 Google 上搜索关于“Mistral AI”的最新消息:

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

agent = Agent(
    instructions=[
        "Use your tools to answer questions about the repo: agno-agi/agno",
        "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 参数

参数类型默认值描述
access_tokenstrNone用于认证的 Github 访问令牌。如果未提供,将使用 GITHUB_ACCESS_TOKEN 环境变量。
base_urlstrNoneGithub Enterprise 安装的可选基础 URL。
search_repositoriesboolTrue启用搜索 Github 仓库。
list_repositoriesboolTrue启用列出用户/组织的仓库。
get_repositoryboolTrue启用获取仓库详情。
list_pull_requestsboolTrue启用列出仓库的拉取请求。
get_pull_requestboolTrue启用获取拉取请求详情。
get_pull_request_changesboolTrue启用获取拉取请求的文件更改。
create_issueboolTrue启用在仓库中创建问题。

Toolkit 函数

函数描述
search_repositories根据查询搜索 Github 仓库。
list_repositories列出给定用户或组织的仓库。
get_repository获取特定仓库的详情。
list_pull_requests列出仓库的拉取请求。
get_pull_request获取特定拉取请求的详情。
get_pull_request_changes获取拉取请求中的文件更改。
create_issue在仓库中创建新问题。

开发者资源