> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/long-term-memory-usage-examples.md).

# 长期记忆使用示例

将 Unreal 长期记忆模式应用于回归学习者、共享设备、首次会话和全新开始的重置流程。

在……之后使用这些模式 [长期记忆快速入门](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/long-term-memory-quick-start.md) 正在工作。每个示例都重点说明在……之前应在聊天机器人组件上设置哪些身份值 `StartSession`。有关分配步骤，请参见 [终端用户身份](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/end-user-identity.md).

### 培训模拟中的回访学习者

安全培训模拟应记住学习者已经完成了阀门检查模块。

**设置：**

* 已为培训角色启用 LTM。
* 学习者有一个已保存的 `SpeakerID`.

**Blueprint 流程：**

1. 加载 `SpeakerID` 从学习者的 `SaveGame` 或账户配置文件中。
2. 设置 `UConvaiChatbotComponent.EndUserID` 和 `UConvaiPlayerComponent.EndUserID` 到已保存的值。
3. 调用 `StartSession` 在聊天机器人组件上。

**预期结果：** 该角色可以引用同一学习者和角色在先前会话中学到的事实。

### 首次玩家资料

新玩家启动应用时没有已存储的身份。

**设置：**

* 项目已收集了显示名称，例如 `Alex`.
* 没有已保存的 `SpeakerID` 该资料。

**Blueprint 流程：**

1. 调用 **Convai 创建 Speaker ID** 并将 **Speaker 名称** 设置为显示名称。
2. 当 **成功时**，保存返回的 `SpeakerID`.
3. 将两个组件的 `EndUserID` 到已保存的值。
4. 调用 `StartSession`.

有关完整的创建工作流，请参见 [Speaker ID 管理](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/speaker-id-management.md).

**预期结果：** Convai 会为该玩家和角色组合创建独立的记忆范围。后续启动应重用已保存的 `SpeakerID`.

### 共享教室设备

在引导练习期间，多个学习者使用同一台机器。设备回退会合并他们的记忆，因此每个学习者都需要明确的身份。

**设置：**

* 每个学习者在与角色互动前选择或登录一个资料。
* 每个资料都存储自己的 `SpeakerID`.

**Blueprint 流程：**

1. 在选择资料时，加载该资料的 `SpeakerID`.
2. 设置聊天机器人和玩家的 `EndUserID` 值，然后 `StartSession`.
3. 将每个资料的 `SpeakerID` 与同一设备上的其他资料分开。

**预期结果：** 尽管所有学习者使用同一设备，该角色仍会分别记住每个学习者。

### 基于账户的身份

企业入职应用已经有用户账户 ID，因此不需要 Speaker ID 记录。

**设置：**

* 账户系统提供一个稳定的用户 ID，例如 `employee-1042`.
* 账户 ID 在不同设备之间不会变化。

**Blueprint 流程：**

1. 加载已登录用户的账户 ID。
2. 设置 `UConvaiChatbotComponent.EndUserID` 和 `UConvaiPlayerComponent.EndUserID` 为账户 ID。
3. 可选地设置 `EndUserMetadata` 在两个组件上使用相同的 JSON 字符串：

```json
{"name": "Jordan Kim", "department": "Facilities"}
```

4. 调用 `StartSession`.

**预期结果：** 记忆跟随账户身份，而不是本地设备。

### 新场景尝试的全新开始

学习者重复进行评估时，应开始新的对话，同时保持相同的长期身份。

**设置：**

* 学习者保持相同的 `SpeakerID` 或账户 ID。
* 项目不应恢复之前的对话会话。

**Blueprint 流程：**

{% tabs %}
{% tab title="Blueprint" %}
调用 **重置对话** 在 **Convai Chatbot** 组件，然后调用 `StartSession`.
{% endtab %}

{% tab title="C++" %}

```cpp
// 仅作示例——将 ChatbotComponent 替换为你项目中的聊天机器人引用。
ChatbotComponent->ResetConversation();
ChatbotComponent->StartSession();
```

{% endtab %}
{% endtabs %}

**预期结果：** 下一次连接将从全新的本地对话链接开始。玩家身份保持不变，因此角色级长期记忆可以继续为该用户累积。

### 移除测试身份

在开发期间，移除通过重复 Speaker ID 实验创建的测试身份。

**Blueprint 流程：**

1. 调用 **Convai 列出 Speaker ID**.
2. 找到该测试 `SpeakerID`.
3. 调用 **Convai 删除 Speaker ID** 中具有该值的项。
4. 清除本地已保存的 `SpeakerID`.

{% hint style="danger" %}
删除 Speaker ID 会移除该用户的用户记录，以及该用户在各个角色中的关联长期记忆记录。可用于已确认的测试数据或用户请求的删除流程。
{% endhint %}

**预期结果：** 该测试 `SpeakerID` 已从 Convai 中移除，并且本地已保存的身份已清除。

### 下一步

{% content-ref url="/pages/49e163546e7059153712733c44aa93aee597bbbe" %}
[终端用户身份](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/end-user-identity.md)
{% endcontent-ref %}

{% content-ref url="/pages/490cd1c53fd291cb3dcb57f385b0eee013c3ae74" %}
[说话者 ID 管理](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/speaker-id-management.md)
{% endcontent-ref %}

{% content-ref url="/pages/1207dad324341231dae358387602c84854559b9c" %}
[排查长期记忆问题](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/troubleshoot-long-term-memory.md)
{% endcontent-ref %}

{% content-ref url="/pages/d52ddbffaafeb3f6c5f97016d40633bc7ea09f16" %}
[LTM Blueprint 参考](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/ltm-blueprint-reference.md)
{% endcontent-ref %}


---

# 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://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/long-term-memory-usage-examples.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.
