> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/documentation/zh/ai-for-your-readers/gitbook-ai-assistant.md).

# AI 助手

AI 助手会根据你的整个知识库，而不仅仅是文档，为访客提供准确、具上下文的答案

<figure><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-bd69cc42bd688271bd63c9e8e3e8b2804ba6e5e2%2F25_03_31_gitbook_assistant%402x.png?alt=media" alt="AI Assistant"><figcaption><p>AI 助手</p></figcaption></figure>

AI 助手使用自然语言为你的用户提供关于文档的快速、准确答案。它会根据你的用户进行个性化设置，可以嵌入到你的网站或产品中，并可显示在已发布文档的侧边栏或搜索框中。

可以把它看作是一位产品专家，在用户最需要的时间和地点随时可供所有用户使用。

助手使用代理式检索，基于用户当前页面、之前阅读过的页面以及之前的对话来理解查询的上下文。

AI Assistant 使用 [AI 积分](https://gitbook.com/docs/documentation/zh/zhang-hu-yu-ji-fei/plans/ai-credits.md)。只有相关回答才会扣除积分。

试着在下面的框中向助手提问：

<p align="center"><button type="button" class="button primary" data-action="ask" data-icon="gitbook-assistant">提问...</button></p>

## 配置 AI 助手 <a href="#how-do-i-use-gitbook-ai" id="how-do-i-use-gitbook-ai"></a>

要配置 AI Assistant，请在站点侧边栏中打开 **自定义** ，然后点击 **AI Assistant**。在这里，你可以启用 Assistant，并自定义其指令、欢迎消息和建议问题。

### 添加自定义说明

自定义说明可调整助手的语气，并添加产品特定的知识或术语，从而让其回答始终与你的整体风格一致。

{% hint style="info" %}
自定义说明可优化助手的语气和知识。它们不能覆盖其内置的安全护栏。
{% endhint %}

### 自定义欢迎消息

欢迎消息是访客在没有活动对话时打开助手时看到的第一条内容。可用它来设定预期，或引导用户进入特定工作流程。

### 添加建议问题

建议问题是在助手以无活动对话状态打开时显示的预写提示。它们可帮助用户了解自己可以问什么，并帮助你将用户引导到有用的答案或工作流程。

#### 建议问题的最佳实践：

* 从真实的用户目标开始（设置、故障排除、集成）。
* 使用你的用户会使用的词语（避免内部代号）。
* 保持具体。“我该如何……？”比“告诉我关于……”更好。
* 覆盖不同意图：快速入门、操作指南、故障排除和参考。

{% hint style="info" %}
如果你要将 Assistant 嵌入产品中，还可以在嵌入配置中动态设置建议。请参阅 [自定义嵌入内容](https://gitbook.com/docs/documentation/zh/publish/embedding/configuration/customizing-docs-embed.md#adding-suggestions).
{% endhint %}

### 选择助手的显示位置 <a href="#choose-your-sites-search-experience" id="choose-your-sites-search-experience"></a>

在 **外观**下，设置 **显示位置** ，以选择读者通过何处访问 Assistant：

* **侧边栏** （默认）：AI Assistant Chat，完整的聊天体验。适用于 Ultimate 站点套餐。
* **搜索框**：AI Assistant Ask，在关键词搜索结果旁显示内嵌回答。适用于 Essential 和 Ultimate 站点套餐。

{% hint style="info" %}
Assistant 的问候语仅适用于侧边栏显示位置，因此当 **显示位置** 设为 **搜索框**.
{% endhint %}

{% hint style="warning" %}
关闭再重新开启 **AI Assistant** 会将 **显示位置** 重置为 **侧边栏**。如果站点使用搜索框显示位置，请在重新启用 Assistant 后再次设置。
{% endhint %}

## 在已发布文档中使用 AI 助手 <a href="#how-do-i-use-gitbook-ai-in-published-docs" id="how-do-i-use-gitbook-ai-in-published-docs"></a>

读者如何访问助手取决于其显示位置。

### 侧边栏位置

访客可以通过三种方式访问 AI 助手：

* 按 <kbd>⌘</kbd> + <kbd>I</kbd> （Mac）或 <kbd>Ctrl</kbd> + <kbd>I</kbd> （PC）
* 点击 **AI 助手** <i class="fa-gitbook-assistant">:gitbook-assistant:</i> 旁边的按钮 **提问或搜索…** 栏
* 在 **提问或搜索…** 栏中输入问题，然后选择菜单顶部的“提问…”选项

### 搜索框位置

当 **显示位置** 设为 **搜索框**时，用户可以直接在 **提问或搜索…** 页面顶部的栏中，与关键词搜索结果并列。

他们可以直接点击打开，也可以按下 <kbd>⌘</kbd> + <kbd>K</kbd> （Mac）或 <kbd>Ctrl</kbd> + <kbd>K</kbd> （PC）。

除了汇总答案外，用户还会看到一个可展开的部分，其中显示助手用于生成答案的来源，以及他们可以点击的相关问题作为后续提问。

Assistant 会根据文档站点的内容以及你通过 [连接](https://gitbook.com/docs/documentation/zh/ai-for-your-readers/connections.md).

{% hint style="warning" %}
Assistant 不会跨不同 [文档站点](https://gitbook.com/docs/documentation/zh/publish/publish-a-docs-site.md).

只有在查看同一站点内已发布的 [分区](https://gitbook.com/docs/documentation/zh/manage-your-site/site-structure/site-sections.md) 时，才能进行多分区搜索。
{% endhint %}

## 搜索已发布文档

无论是否启用助手，每个站点都会自动启用关键词搜索。

你的用户可以在文档站点内搜索关键词，并快速跳转到整个站点中的特定页面或页面部分。

## 将 AI 助手嵌入到你的产品中

您可以将 AI 助手直接嵌入到产品或网站中，让访客无需离开您的应用即可即时获取 AI 帮助。助手可以作为以下内容的一部分嵌入： [文档嵌入](https://gitbook.com/docs/documentation/zh/publish/embedding.md)，其中包括用于 AI 对话的“助手”选项卡、用于限定范围内探索内容的“搜索”选项卡，以及用于浏览文档的“文档”选项卡。

选择适合你技术栈的嵌入方式：

* [**独立脚本标签**](https://gitbook.com/docs/documentation/zh/publish/embedding/implementation/script.md) – 使用 `<script>` 标签快速设置
* [**Node.js/NPM**](https://gitbook.com/docs/documentation/zh/publish/embedding/implementation/nodejs.md) – 服务器端或构建时集成
* [**React 组件**](https://gitbook.com/docs/documentation/zh/publish/embedding/implementation/react.md) – 预构建的 React 组件

### 其他助手嵌入指南：

* [在需要身份验证的文档中使用嵌入式 Assistant](https://gitbook.com/docs/documentation/zh/publish/embedding/using-with-authenticated-docs.md) – 如果你的文档需要登录，则必须使用
* [自定义 Assistant 嵌入](https://gitbook.com/docs/documentation/zh/publish/embedding/configuration/customizing-docs-embed.md) – 欢迎消息、操作和建议
* [创建自定义嵌入工具](https://gitbook.com/docs/documentation/zh/publish/embedding/configuration/creating-custom-tools.md) – 将 Assistant 连接到你的 API
* [API 参考](https://gitbook.com/docs/documentation/zh/publish/embedding/configuration/reference.md) – 所有可用的方法和事件

## 扩展 AI 助手的知识

AI Assistant 可以通过 [连接](https://gitbook.com/docs/documentation/zh/ai-for-your-readers/connections.md) 和 [MCP 服务器](https://gitbook.com/docs/documentation/zh/ai-for-your-readers/mcp-servers-for-published-docs.md).

当你希望 GitBook 将记录同步到你的网站时，可以使用连接；当你希望将 AI 助手接入自定义工具时，可以使用 MCP 服务器。

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th>最适合</th></tr></thead><tbody><tr><td><strong>连接</strong></td><td><p>连接最适合内容密集型来源：</p><ul><li>GitHub 问题和讨论</li><li>Slack 或 Discord 对话</li><li>支持内容</li><li>外部文档、帮助中心和网站</li></ul></td></tr><tr><td><strong>MCP 服务器</strong></td><td><p>MCP 服务器最适合实时工具和数据：</p><ul><li>当前账户或产品状态</li><li>经常变化的内部系统</li><li>创建工单或提交 bug 等操作</li><li>你不想同步到 GitBook 的来源</li></ul></td></tr></tbody></table>

{% tabs %}
{% tab title="添加连接" %}
{% stepper %}
{% step %}
**打开你网站的设置**

打开站点控制面板，然后选择 **设置** → **连接**.
{% endstep %}

{% step %}
**连接一个来源**

选择一种来源类型。然后对其进行授权，或输入要导入的 URL。
{% endstep %}

{% step %}
**向 AI 助手公开记录**

开启 **在搜索 / Assistant 中公开** 选项。

GitBook 随后可以在搜索和 AI 助手中使用这些记录。
{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="添加 MCP 服务器" %}
{% stepper %}
{% step %}
**打开你网站的设置**

打开站点控制面板，然后选择 **设置** → **AI 与 MCP**.
{% endstep %}

{% step %}
**添加新服务器**

在 MCP 服务器表格中，点击 **添加 MCP 服务器**.
{% endstep %}

{% step %}
**输入服务器详情**

为服务器命名。添加其 URL。

然后配置 GitBook 必须在每个请求中发送的任何 HTTP 标头。
{% endstep %}
{% endstepper %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://gitbook.com/docs/documentation/zh/ai-for-your-readers/gitbook-ai-assistant.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
