> ## Documentation Index
> Fetch the complete documentation index at: https://ikun.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Github

````md theme={null}
---
title: Github
---

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

## 先决条件

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

```shell
pip install -U PyGithub
````

```shell theme={null}
export GITHUB_ACCESS_TOKEN=***
```

## 示例

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

```python cookbook/tools/github_tools.py theme={null}
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_token`             | `str`  | `None` | 用于认证的 Github 访问令牌。如果未提供，将使用 GITHUB\_ACCESS\_TOKEN 环境变量。 |
| `base_url`                 | `str`  | `None` | Github Enterprise 安装的可选基础 URL。                          |
| `search_repositories`      | `bool` | `True` | 启用搜索 Github 仓库。                                         |
| `list_repositories`        | `bool` | `True` | 启用列出用户/组织的仓库。                                           |
| `get_repository`           | `bool` | `True` | 启用获取仓库详情。                                               |
| `list_pull_requests`       | `bool` | `True` | 启用列出仓库的拉取请求。                                            |
| `get_pull_request`         | `bool` | `True` | 启用获取拉取请求详情。                                             |
| `get_pull_request_changes` | `bool` | `True` | 启用获取拉取请求的文件更改。                                          |
| `create_issue`             | `bool` | `True` | 启用在仓库中创建问题。                                             |

## Toolkit 函数

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

## 开发者资源

* 查看 [Tools](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/github.py)
* 查看 [Cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/tools/github_tools.py)

```
```
