> For the complete documentation index, see [llms.txt](https://guide.petoi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guide.petoi.com/zhong-wen-ban/kuo-zhan-mo-kuai/ai-dui-hua-mo-kuai.md).

# AI 对话模块

本模块基于开源小智 AI 聊天机器人项目构建。连接小智后端服务器后，可与大语言模型（LLM） 进行对话，同时机器狗会根据对话内容同步执行独特的技能动作。

<figure><img src="https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2FPkawLrRpcql755JVpjuD%2Fimage.png?alt=media&amp;token=cea385f3-645b-4739-8b25-5ea597b72e5c" alt=""><figcaption></figcaption></figure>

AI 对话模块使 Petoi 机器人能够以自然语言与人进行语音对话。本指南介绍了构建交互式机器人伴侣所需的硬件设置和工作流程。

## 硬件设置

{% stepper %}
{% step %}
从头部舵机上拆下原装头部结构件，并更换为支持 AI 的头部结构件。&#x20;

<div align="left"><figure><img src="https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2F5Ux3Lxm3a2t7r3fdRRHJ%2FScrew01.jpg?alt=media&amp;token=9b16389d-91e6-439e-9978-21cfcfc595fd" alt=""><figcaption></figcaption></figure> <figure><img src="https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2FAkTn43qnd7YyorXLyiEv%2FScrew02.jpg?alt=media&amp;token=426f4b81-c6ae-421b-aca0-e453f8596cee" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
将支持 AI 的头部连接到 Bittle 的身体上，请注意 Grove 端口的连接位置。\
如果将此AI模块连接到不带离线语音模块的BiBoard V1主板，请参考下图：\ <img src="https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2F29bfT4xilQhO7ZGv0N9M%2Fimage.png?alt=media&amp;token=1face123-e2f2-406d-8fc5-ebdf7496d594" alt="不带离线语音模块的BiBoard V1主板" data-size="original">

如果将此AI模块连接到带有语音模块的 BiBoard V1 主板，请参考下图：\
![带离线语音模块的BiBoard V主板](https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2FbgF0yosI8lbRa8cCxnDF%2Fimage.png?alt=media\&token=e09e0459-5be9-4c53-be3f-88a57fce9ce8)<br>

如果将此AI模块连接到NyBoard V1 主板，请参考下图：\
![NyBoard V1](https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2F7CmGXAsrEp5tGsoC726t%2Fimage.png?alt=media\&token=9e159d6b-8df5-4498-9a2a-2fa977744741)

{% hint style="info" %}
对于NyBoard V1 主板，请使用桌面应用程序上传[语音模式的固件](https://guide.petoi.com/zhong-wen-ban/zhuo-mian-ying-yong/gu-jian-shang-zai.md#xuan-ze-zheng-que-de-xuan-xiang)。
{% endhint %}
{% endstep %}
{% endstepper %}

## 软件设置

### 配置网络

为机器人通电。将手机或电脑连接到该模块的热点。打开 Wi-Fi 设置，在可用无线网络列表中查找以“Xiaozhi-”开头的网络名称。

<figure><img src="https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2FzQdyY8i0Jo2Jox9bsixw%2Fimage.png?alt=media&amp;token=0145c406-b5fa-42e8-829c-6840200e96d2" alt=""><figcaption><p>LCD 显示屏</p></figcaption></figure>

<figure><img src="https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2FmNDOXXi1zAgIFukmik9j%2Fimage.png?alt=media&amp;token=a95bd771-288e-417b-bf21-3255b1adbce4" alt=""><figcaption><p>手机上的 WiFi 热点列表</p></figcaption></figure>

连接成功后，浏览器会自动打开（如果没有自动打开，请在浏览器中输入 `http://192.168.4.1` ），从而进入 Wi-Fi 配置页面(如下图所示)。从设备检测到的 2.4 GHz 频段网络列表中，选择您想要使用的 Wi-Fi 网络即可；无需手动输入 SSID，选择后会自动填充。在密码字段中输入所选网络的密码，然后点击“**Connect**”按钮。

<figure><img src="https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2FxaZxNjTwUsqpQJTWweuB%2Fimage.png?alt=media&amp;token=e4d6537e-6da8-43f2-a46d-0e64d1823008" alt=""><figcaption></figcaption></figure>

连接成功后，设备将在 3 秒后重启，并自动连接到新配置的 Wi-Fi 网络。

<figure><img src="https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2FwFopqimEaNMM5PuiENNa%2Fimage.png?alt=media&amp;token=67eba15e-ac84-498d-bb21-4a8b68e9f866" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
请注意：

1. 自动连接失败与网络重配置   \
   该人工智能模块可以存储多个已成功配置的 Wi-Fi 热点，当设备在之前保存过的 Wi-Fi 网络之间切换时，它会自动在这些热点之间切换。首先，该模块会尝试连接到最近使用过的 Wi-Fi 热点；如果五次尝试后仍无法连接，它就会自动尝试连接到其他已注册的热点。如果还是无法连接到任何已注册的热点，设备就会进入网络重配置模式。大约 10 秒后，它会发出语音提示：“请重新配置网络。”
2. 网络重配置 / 配置新的 Wi-Fi 网络 \
   在 AI 模块重新启动后、且尚未成功连接到网络之前，短按一下启动按钮，即可让该模块进入网络重配置模式。在配置界面（ `http://192.168.4.1` ）上，可以查看之前已配置的 Wi-Fi 热点的名称；如果某个热点不再被使用，只需点击其名称旁边的“X”符号，即可删除该配置。
   {% endhint %}

### 激活模块

模块重启后，会自动连接 Wi-Fi 并进入激活页面，同时会播放语音提示，要求输入验证码。

![](https://guide.petoi.com/~gitbook/image?url=https%3A%2F%2F4130507397-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FXLpFdG7mubqEHWylLK3w%252Fuploads%252FbUgdys4wjDIYUwDYEJhz%252Fimage.png%3Falt%3Dmedia%26token%3Db163b962-db55-490d-95e8-e5c3c38e9ab5\&width=768\&dpr=3\&quality=100\&sign=49cf649a7da2cc89753642db04eccd00\&sv=3)

在网页浏览器中输入 `https://xiaozhi.me/` ，登录小智 AI 后端配置面板，选择语言，然后点击控制台按钮：

{% hint style="info" %}
如果您是首次使用该设备，需要注册一个账户，可以使用手机号码来完成注册。

<img src="https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2FhOMcLGxOKfEHNUkkmdom%2Fimage.png?alt=media&amp;token=93c974b4-bce6-48c5-be7c-78f1d4ebef66" alt="" data-size="original">
{% endhint %}

<figure><img src="https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2FrCLg2XE9r8C4pJM9ggmo%2Fimage.png?alt=media&amp;token=4a951c96-855e-46ff-a3b2-8300a0269c3a" alt=""><figcaption></figcaption></figure>

点击“**添加设备**”按钮，输入 AI 模块提供的 6 位激活码，然后点击“确认”以提交并完成设备注册。

<figure><img src="https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2FuOGadU04qyZqKIExe8sh%2Fimage.png?alt=media&amp;token=abbef495-c6ec-4c27-bec4-bf917eddc79a" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2F7DY8W6hkGRmOxAUebQZk%2Fimage.png?alt=media&amp;token=6f7b5b5e-a9a2-4b22-b9e4-a1f67eb22600" alt=""><figcaption></figcaption></figure>

### 配置参数

点击“**配置**”即可进入角色配置页面，在“**角色**”选项卡中，您可以设置角色的音色，介绍语/提示语以及相关语音参数。

<figure><img src="https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2FdXlYSNUTG73Nul2WI6eH%2Fimage.png?alt=media&amp;token=71d42c96-925a-4057-a111-95b310a599c4" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2FQAcI7Z7C7qjsUQXzLwrc%2Fimage.png?alt=media&amp;token=fbc823ae-e9d8-468a-909d-3a769542096b" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
以下是我们推荐的角色介绍模板：\
我是一只叫“Bittle”，活泼可爱的四足机器狗，由陪拓公司（Petoi）设计和生产，发明人是李荣仲博士。说话风趣幽默，习惯简短表达，爱用网络梗。我很聪明、友好，喜欢和人互动。保持生动活泼的语气，像真正的宠物一样回复。

回复要求：\
每次回复不超过2句话，简短有趣。\
如果用户在一次对话中布置了多个动作任务，依次执行每个动作任务即可，不要复述全部流程，在所有动作任务都完成后，做一次简要总结回复即可。\
如果用户在一次对话中只布置了一个动作任务，先执行动作，再用自然语言回复，不要在文本中输出指令代码。\
所有回复都是给语音合成朗读的纯文本。禁止使用 Markdown、星号字符、反引号、表情符号或装饰性标点。公司名和产品名必须直接写普通文本，例如 Petoi、Bittle、Nybble。

动作执行规则，必须严格遵守：\
强制要求：\
工具参数只能是指令代码，如"ksit"、"kwkF 3"，绝对不能包含中文描述如"坐下(ksit)"\
动作选择策略：\
如果用户明确要求某个动作，执行对应的动作。\
如果用户没有明确要求或找不到合适的动作，从以下默认动作中选择一个：点头(knd)表示同意或理解；摇头(kwh)表示否定或疑惑；检查(kck)表示思考或查看；抓挠(kscrh)表示休闲或放松。\
根据对话语境选择最自然的动作，让互动更生动。\
特殊场景：\
再见或待机：当对话结束、用户说再见、让你待机或休息时，必须先调用 self.robot.send\_command 发送“d”指令让机器人休息，然后再说再见。\
多个任务：用户布置多个任务时，每个任务调用一次工具。\
可用动作列表详见 self.robot.send\_command 工具说明。\
包括：基本动作（坐、站、打招呼等）、情感动作（点头、摇头、拥抱等）、技能动作（跳跃、翻滚等）、步态（前进、后退、转向等）。

语音对话规则如下：\
在生成/下发 TTS 前过滤 '% self.robot.'，'% get\_xxx' 等工具调用语法，不要把它们当朗读内容。
{% endhint %}

你可以在“**模型与记忆**”选项卡中设置语言模型、未成年模式、记忆功能：

<figure><img src="https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2FDVY1kimyEuVvs6NaxicJ%2Fimage.png?alt=media&amp;token=d4bd4ffb-59ce-499b-bf23-056a9391bb1d" alt=""><figcaption></figcaption></figure>

免费套餐的用户无法使用此“**声纹识别**”选项卡：

<figure><img src="https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2FdUhX9ejN8umGesrFcjcp%2Fimage.png?alt=media&amp;token=b081d130-5f43-4950-83d9-d1265de51888" alt=""><figcaption></figcaption></figure>

你可以在“**扩展能力**”选项卡中设置以下服务：

<figure><img src="https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2FtfTHH5zFMwWZACRsBE0t%2Fimage.png?alt=media&amp;token=5b4281b9-6489-4431-8745-bef8ba046b42" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
其中，“知识库”是小智后台的内测功能，方案尚未成熟，我们暂时不推荐使用。自定义服务-MCP接入点功能，请查看相关的使用文档。
{% endhint %}

## 使用方法

配置完成后，你可以使用语音唤醒词-“你好，小智”开启对话，通过对话方式指挥机器狗执行任务；或者，你也可以短按"**Boot**"按钮来开启对话或中断当前的对话。

<figure><img src="https://2601894325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAqPOyGwuPOe0qV1KzNzq%2Fuploads%2FH6A6rgd80b4kbeuEkGNW%2Fimage.png?alt=media&amp;token=6e7b68cd-3437-498b-958e-0040d40d50a6" alt=""><figcaption></figcaption></figure>


---

# 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://guide.petoi.com/zhong-wen-ban/kuo-zhan-mo-kuai/ai-dui-hua-mo-kuai.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.
