> 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/ltm-blueprint-reference.md).

# LTM Blueprint 参考

Unreal 长期记忆 Blueprint 节点、说话者 ID 数据、组件属性以及启动期间使用的会话字段的参考。

此参考列出了 Convai Unreal Engine 插件中公开的长期记忆接口。LTM 管理节点位于 `Convai|LTM` 蓝图类别中。

对于连接时使用的身份信息，插件会在 `EndUserID` 和 `EndUserMetadata` 中读取这些值，来源是 `UConvaiChatbotComponent` ，通过 `IConvaiConnectionInterface` 在 `StartSession` 构建连接参数时读取。调用 `StartSession`.

### LTM 节点

本页中的所有节点都是异步代理节点。每个节点都提供 **成功时** 和 **失败时** 委托。

#### Convai 创建说话者 ID

创建说话者 ID 记录。

| 项目        | 类型                                                                                          | 说明                           |
| --------- | ------------------------------------------------------------------------------------------- | ---------------------------- |
| **说话者名称** | `FString` 输入                                                                                | 人类可读的说话者名称。值为空时，请求发送前即会失败。   |
| **设备 ID** | `FString` 输入                                                                                | 可选的设备标识符。为空时不会包含在请求中。        |
| **成功时**   | `FConvaiSpeakerInfo` 委托                                                                     | 返回已创建的说话者记录。                 |
| **失败时**   | `FConvaiSpeakerInfo` 委托                                                                     | 返回一个空的 `FConvaiSpeakerInfo`. |
| C++ 工厂函数  | `UConvaiCreateSpeakerID::ConvaiCreateSpeakerIDProxy(FString SpeakerName, FString DeviceId)` | 蓝图节点使用的静态工厂函数。               |

源代码验证日志 `Speaker name is empty` 当 **说话者名称** 为空时。

#### Convai 列出说话者 ID

列出与已配置 API 密钥关联的说话者 ID 记录。

| 项目       | 类型                                                 | 说明             |
| -------- | -------------------------------------------------- | -------------- |
| **成功时**  | `TArray<FConvaiSpeakerInfo>` 委托                    | 返回说话者列表。       |
| **失败时**  | `TArray<FConvaiSpeakerInfo>` 委托                    | 返回空数组。         |
| C++ 工厂函数 | `UConvaiListSpeakerID::ConvaiListSpeakerIDProxy()` | 蓝图节点使用的静态工厂函数。 |

#### Convai 删除 Speaker ID

删除 Speaker ID 记录。

| 项目             | 类型                                                                      | 说明                                 |
| -------------- | ----------------------------------------------------------------------- | ---------------------------------- |
| **Speaker ID** | `FString` 输入                                                            | 要删除的 Speaker 记录标识符。值为空时，请求发送前就会失败。 |
| **成功时**        | `FString` 委托                                                            | 返回响应字符串。                           |
| **失败时**        | `FString` 委托                                                            | 返回 `Http req failed`.              |
| C++ 工厂函数       | `UConvaiDeleteSpeakerID::ConvaiDeleteSpeakerIDProxy(FString SpeakerID)` | 蓝图节点使用的静态工厂函数。                     |

#### Convai 获取 LTM 状态

返回角色的 LTM 启用状态。

| 项目        | 类型                                                                  | 说明                                   |
| --------- | ------------------------------------------------------------------- | ------------------------------------ |
| **角色 ID** | `FString` 输入                                                        | 来自 Convai 控制面板的角色 ID。值为空时，请求发送前就会失败。 |
| **成功时**   | `bool` 名为 **Status**                                                | 返回 `true` 表示已启用 LTM， `false` 表示已禁用。  |
| **失败时**   | `bool` 名为 **Status**                                                | 返回 `false`.                          |
| C++ 工厂函数  | `UConvaiGetLTMStatus::ConvaiGetLTMStatusProxy(FString CharacterID)` | 蓝图节点使用的静态工厂函数。                       |

#### Convai 设置 LTM 状态

通过发送 `memorySettings.enabled` 更新来启用或禁用角色的 LTM。

| 项目        | 类型                                                                                | 说明                                   |
| --------- | --------------------------------------------------------------------------------- | ------------------------------------ |
| **角色 ID** | `FString` 输入                                                                      | 来自 Convai 控制面板的角色 ID。值为空时，请求发送前就会失败。 |
| **B 启用**  | `bool` 输入                                                                         | `true` 启用 LTM； `false` 禁用 LTM。       |
| **成功时**   | `FString` 委托                                                                      | 返回响应字符串。                             |
| **失败时**   | `FString` 委托                                                                      | 返回代理可用的响应字符串。                        |
| C++ 工厂函数  | `UConvaiSetLTMStatus::ConvaiSetLTMStatusProxy(FString CharacterID, bool bEnable)` | 蓝图节点使用的静态工厂函数。                       |

### 数据结构

#### FConvaiSpeakerInfo

| 字段          | 类型        | 类别             | 说明                  |
| ----------- | --------- | -------------- | ------------------- |
| `SpeakerID` | `FString` | `Speaker Info` | 要保存并作为 `EndUserID`. |
| `Name`      | `FString` | `Speaker Info` | Convai 返回的说话人名称。    |
| `DeviceID`  | `FString` | `Speaker Info` | Convai 返回的设备标识符。    |

### UConvaiChatbotComponent

蓝图显示名称： **Convai 聊天机器人**.

| 成员                    | 类型        | 说明符                                              | 说明                                                                            |
| --------------------- | --------- | ------------------------------------------------ | ----------------------------------------------------------------------------- |
| `EndUserID`           | `FString` | `BlueprintReadWrite`, `EditAnywhere`，类别 `Convai` | 通过 `GetEndUserID()`在连接时发送的玩家身份。请在 `StartSession`.                             |
| `EndUserMetadata`     | `FString` | `BlueprintReadWrite`, `EditAnywhere`，类别 `Convai` | 通过 `GetEndUserMetadata()`.                                                    |
| `SessionID`           | `FString` | `BlueprintReadWrite`，类别 `Convai`, `Replicated`   | 本地对话链接标记。默认值为 `"-1"`。由 `ResetConversation()`清除。WebRTC 不会发送此标记 `StartSession`. |
| `ResetConversation()` | `void`    | `BlueprintCallable`，类别 `Convai`                  | 将 `SessionID` 设置为 `"-1"`.                                                     |
| `StartSession()`      | `void`    | `BlueprintCallable`，类别 \`Convai                  | Session\`                                                                     |

`UConvaiChatbotComponent` 实现了 `IConvaiConnectionInterface`。其 `GetEndUserID()` 和 `GetEndUserMetadata()` 重写函数会返回组件属性。

### UConvaiPlayerComponent

蓝图显示名称： **Convai 玩家**.

| 成员                           | 类型                                         | 说明符                                                                              | 说明                                                              |
| ---------------------------- | ------------------------------------------ | -------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| `EndUserID`                  | `FString`                                  | `EditAnywhere`，类别 `Convai`, `Replicated`, `BlueprintSetter = SetEndUserID`       | 玩家组件上的玩家身份标识。设置为与聊天机器人中的值一致，以确保项目一致性。                           |
| `SetEndUserID()`             | `void (FString NewEndUserID)`              | `BlueprintCallable`, `BlueprintInternalUseOnly`，类别 `Convai`                      | 设置 `EndUserID`。当组件启用复制时，调用 `SetEndUserIDServer()` 。             |
| `SetEndUserIDServer()`       | `void (const FString& NewEndUserID)`       | `Server`, `Reliable`，类别 \`Convai                                                 | Network\`                                                       |
| `EndUserMetadata`            | `FString`                                  | `EditAnywhere`，类别 `Convai`, `Replicated`, `BlueprintSetter = SetEndUserMetadata` | 可选的 JSON 元数据。设置为与聊天机器人中的值一致。                                    |
| `SetEndUserMetadata()`       | `void (FString NewEndUserMetadata)`        | `BlueprintCallable`, `BlueprintInternalUseOnly`，类别 `Convai`                      | 设置 `EndUserMetadata`。当组件启用复制时，调用 `SetEndUserMetadataServer()` 。 |
| `SetEndUserMetadataServer()` | `void (const FString& NewEndUserMetadata)` | `Server`, `Reliable`，类别 \`Convai                                                 | Network\`                                                       |

源代码说明： `UConvaiPlayerComponent` 声明了 `EndUserID` 和 `EndUserMetadata` ，并为它们声明了复制元数据和服务器 RPC 设置函数。在当前源代码中， `GetLifetimeReplicatedProps()` 注册了 `PlayerName`；但未注册 `EndUserID` 或 `EndUserMetadata`.

### 设备回退工具

| 成员                                          | 类别       | 说明     |
| ------------------------------------------- | -------- | ------ |
| `UConvaiUtils::GetDeviceUniqueIdentifier()` | \`Convai | 实用工具\` |

### 源文件

* `Source/Convai/Public/RestAPI/ConvaiLTMProxy.h`
* `Source/Convai/Private/RestAPI/ConvaiLTMProxy.cpp`
* `Source/Convai/Public/ConvaiDefinitions.h`
* `Source/Convai/Private/ConvaiDefinitions.cpp`
* `Source/Convai/Public/ConvaiChatbotComponent.h`
* `Source/Convai/Private/ConvaiChatbotComponent.cpp`
* `Source/Convai/Public/ConvaiPlayerComponent.h`
* `Source/Convai/Private/ConvaiPlayerComponent.cpp`
* `Source/Convai/Public/ConvaiConnectionInterface.h`
* `Source/Convai/Public/ConvaiUtils.h`

### 相关页面

{% content-ref url="/pages/49e163546e7059153712733c44aa93aee597bbbe" %}
[终端用户身份](https://docs.convai.com/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 管理](https://docs.convai.com/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/02906b279025410eed0c91dd64f1012b0304b626" %}
[为角色配置记忆](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)
{% 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/ltm-blueprint-reference.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.
