UserMessage
public final class UserMessage extends Msg
io/agentscope/core/message/UserMessage.java:37–174用户消息,在智能体、模型与前端之间传递结构化消息和事件。位于 io.agentscope.core.message 包,继承自 Msg。核心成员包括 builder、UserMessage。
A Msg with MsgRole#USER pinned at construction time.
Provides convenience constructors that take a String directly
(wrapped into a TextBlock) or any combination of ContentBlocks,
removing the boilerplate of Msg.builder().role(USER).content(...).build().
Also offers an independent Builder for cases that need to set
metadata, timestamp, usage or generateReason.
Allowed content blocks follow the rules enforced by Msg's constructor:
text, image, audio, video, and data blocks.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Builder | 类class | 构建器,用于构建并配置目标实例。 Fluent builder for `UserMessage`. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public UserMessage(String text) | 初始化 `UserMessage` 实例。 Creates a new instance. |
public UserMessage(String name, String text) | 初始化 `UserMessage` 实例。 Creates a new instance. |
public UserMessage(ContentBlock... blocks) | 初始化 `UserMessage` 实例。 Creates a new instance. |
public UserMessage(String name, ContentBlock... blocks) | 初始化 `UserMessage` 实例。 Creates a new instance. |
public UserMessage(List<ContentBlock> blocks) | 初始化 `UserMessage` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static Builder builder()static | 返回构建器实例。 Creates a builder for `UserMessage` with a randomly generated ID
and the current timestamp pre-populated. |
构造器详情Constructor Detail
UserMessage
public UserMessage(String text)
初始化 UserMessage 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
text | String | 文本(类型 `String`)。The text. |
io/agentscope/core/message/UserMessage.java:39–41UserMessage
public UserMessage(String name, String text)
初始化 UserMessage 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
name | String | 名称(类型 `String`)。The name. |
text | String | 文本(类型 `String`)。The text. |
io/agentscope/core/message/UserMessage.java:43–52UserMessage
public UserMessage(ContentBlock... blocks)
初始化 UserMessage 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
blocks varargs | ContentBlock... | 内容块列表(类型 `ContentBlock...`)。The blocks. |
io/agentscope/core/message/UserMessage.java:54–56UserMessage
public UserMessage(String name, ContentBlock... blocks)
初始化 UserMessage 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
name | String | 名称(类型 `String`)。The name. |
blocks varargs | ContentBlock... | 内容块列表(类型 `ContentBlock...`)。The blocks. |
io/agentscope/core/message/UserMessage.java:58–67UserMessage
public UserMessage(List<ContentBlock> blocks)
初始化 UserMessage 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
blocks | List<ContentBlock> | 内容块列表(类型 `List`)。The blocks. |
io/agentscope/core/message/UserMessage.java:69–71方法详情Method Detail
builder
public static Builder builder()
返回构建器实例。
Creates a builder for UserMessage with a randomly generated ID and the current timestamp pre-populated.
Builderio/agentscope/core/message/UserMessage.java:88–90嵌套类详情Nested Class Detail
Builder
public static final class Builder extends Msg.Builder构建器,用于构建并配置目标实例。位于 io.agentscope.core.message 包,继承自 Msg.Builder。核心成员包括 role、id、name、content、textContent、metadata。
Fluent builder for UserMessage. The role is fixed to
MsgRole#USER and #role(MsgRole) is unsupported.
继承成员Inherited Members
MsgbuilderForRole, generateId, currentTimestamp, getId, getName, getRole, getContent, getMetadata, getTimestamp, getUsage, hasContentBlocks, getContentBlocks, getFirstContentBlock, getFirstContentBlock, hasStructuredData, getStructuredData, getStructuredData, getTextContent, getChatUsage, getGenerateReason, withGenerateReason, withContent, withMetadata, METADATA_GENERATE_REASON, METADATA_CONFIRM_RESULTS, METADATA_CONFIRM_REQUEST_REPLY_ID, METADATA_EXTERNAL_EXECUTION_REQUEST_REPLY_ID, METADATA_SYNTHETIC, METADATA_REMINDER_KIND