> 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/configure-memory-for-a-character.md).

# 为角色配置记忆

为 Unreal 角色启用长期记忆，验证仪表板设置，并在需要时重置本地对话链接。

配置 Convai 角色，使其能够记住回访玩家。启用角色级 LTM 设置，确认该设置已生效，并在需要开启新对话线程时重置本地对话链接。

### 前提条件

* 已安装 Convai Unreal Engine 插件并配置 API 密钥。
* 角色 Actor 上有一个 `UConvaiChatbotComponent` 且具有有效的 `CharacterID`.
* 已配置玩家身份。请参阅 [终端用户身份](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/end-user-identity.md).

### 为角色启用 LTM

在 Convai 控制面板中，新角色默认禁用 LTM。请为每个需要构建持久记忆的角色启用 LTM。

{% stepper %}
{% step %}

#### 检查当前状态

添加 **Convai Get LTM Status** （位于 `Convai|LTM` 类别中）。

将 **Character ID** 设为 Convai 控制面板中的角色 ID。 **On Success** 委托会返回 **Status** ，类型为 `bool`.
{% endstep %}

{% step %}

#### 如有需要，启用记忆

如果 **Status** 为 `false`，则调用 **Convai Set LTM Status** 并使用相同的 **Character ID** ，同时将 **B Enable** 设为 `true`.

将 **On Success** 绑定到一个可见的确认方式，例如测试时使用 **Print String** 。
{% endstep %}

{% step %}

#### 验证设置

再次调用 **Convai Get LTM Status** 仅当 **Status** 返回 `true`.
{% endstep %}
{% endstepper %}

### 时才继续。重置对话链接

使用 `ResetConversation()` 当玩家开始新一轮游戏、切换配置文件，或需要开启新的对话会话但不删除长期记忆时。

{% tabs %}
{% tab title="蓝图" %}
在 **重置对话** 组件 **Convai 聊天机器人** 上调用。
{% endtab %}

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

```cpp
ChatbotComponent->ResetConversation();
```

{% endtab %}
{% endtabs %}

`ResetConversation()` 会将本地 `SessionID` 属性设置为 `"-1"`。它不会删除玩家在 Convai 中的 Speaker ID 或单条记忆记录。相同的 `EndUserID` 会继续用于限定该玩家的长期记忆。

{% hint style="info" %}
`UConvaiChatbotComponent.SessionID` 默认值为 `"-1"` ，并会由 `ResetConversation()`清除。WebRTC 连接不会发送此属性。可将其用于本地重置跟踪或 HTTP Bot Query 流程。
{% endhint %}

### 验证配置

在 `StartSession`之前，请确认：

* **Convai Get LTM Status** 返回 `true`.
* `UConvaiChatbotComponent.EndUserID` 已设置为非空且稳定的值。
* `SessionID` 在 `"-1"` 之后为 `ResetConversation()`；如果要使用相同身份继续对话，则保持不变。

有关身份分配步骤，请参阅 [最终用户身份](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/end-user-identity.md).

### 后续步骤

{% content-ref url="/pages/fe714c4b4449c797215a2b49fe82fef8879c959a" %}
[长期记忆使用示例](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)
{% endcontent-ref %}

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

{% content-ref url="/pages/1207dad324341231dae358387602c84854559b9c" %}
[排查长期记忆问题](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/long-term-memory/troubleshoot-long-term-memory.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/configure-memory-for-a-character.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.
