> 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).

# 为角色配置记忆

配置 Convai 角色，使其能够记住回归玩家。启用角色级 LTM 设置，确认其已激活，并在需要新的会话线程时重置本地对话链接。

### 先决条件

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

### 为角色启用 LTM

在 Convai 仪表板中新建角色默认禁用 LTM。请为每个需要构建持久记忆的角色启用它。

{% stepper %}
{% step %}

#### 检查当前状态

添加 **Convai 获取 LTM 状态** 在 `Convai|LTM` 类别下。

设置 **角色 ID** 到 Convai 仪表板中的角色 ID。该 **成功时** 委托返回 **Status** 作为一个 `bool`.
{% endstep %}

{% step %}

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

如果 **Status** 为 `false`，则调用 **Convai Set LTM Status** 使用相同的 **角色 ID** 是位于 **B 启用** 设置为 `true`.

Bind **成功时** 为可见的确认，例如 **打印字符串** 在测试时。
{% endstep %}

{% step %}

#### 验证该设置

调用 **Convai 获取 LTM 状态** 再次。仅在 **Status** 返回 `true`.
{% endstep %}
{% endstepper %}

### 重置对话链接

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

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

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

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

{% endtab %}
{% endtabs %}

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

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

### 验证配置

在……之前 `StartSession`，请确认：

* **Convai 获取 LTM 状态** 返回 `true`.
* `UConvaiChatbotComponent.EndUserID` 已设置为非空且稳定的值。
* `SessionID` 为 `"-1"` 在 `ResetConversation()`，或者在继续使用相同身份时保持不变。

有关身份分配步骤，请参见 [终端用户身份](/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" %}
[长期记忆使用示例](/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 参考](/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" %}
[排查长期记忆问题](/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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
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>
```

The question should be specific, self-contained, and written in natural language.
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.
