AS AgentScopeAPI 手册 / API Reference

Builder

public static final class Builder extends Msg.Builder
源码Source io/agentscope/core/message/UserMessage.java:96–173

构建器,用于构建并配置目标实例。位于 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.

构造器摘要Constructor Summary

构造器Constructor说明Description
public Builder()
初始化 `Builder` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public Builder role(MsgRole role)
设置角色。
Unsupported on `UserMessage.Builder`: role is fixed to USER.
public Builder id(String id)
设置标识。
Performs the id operation.
public Builder name(String name)
设置名称。
Performs the name operation.
public Builder content(List<ContentBlock> content)
设置内容。
Performs the content operation.
public Builder content(ContentBlock block)
设置内容。
Performs the content operation.
public Builder content(ContentBlock... blocks)
设置内容。
Performs the content operation.
public Builder textContent(String text)
设置文本内容。
Performs the text content operation.
public Builder metadata(Map<String, Object> metadata)
设置元数据。
Performs the metadata operation.
public Builder timestamp(String timestamp)
设置时间戳。
Performs the timestamp operation.
public Builder usage(ChatUsage usage)
设置用量。
Performs the usage operation.
public Builder generateReason(GenerateReason reason)
设置该配置项。
Performs the generate reason operation.
public UserMessage build()
构建并返回最终实例。
Creates and returns an instance.

构造器详情Constructor Detail

Builder

public Builder()

初始化 Builder 实例。

Creates a new instance.

源码Source io/agentscope/core/message/UserMessage.java:98–100

方法详情Method Detail

role

public Builder role(MsgRole role)

设置角色。

Unsupported on UserMessage.Builder: role is fixed to USER.

参数Parameters
名称Name类型Type说明Description
roleMsgRole角色(类型 `MsgRole`)。The role.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/message/UserMessage.java:103–107

id

public Builder id(String id)

设置标识。

Performs the id operation.

参数Parameters
名称Name类型Type说明Description
idString标识(类型 `String`)。The id.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/message/UserMessage.java:109–113

name

public Builder name(String name)

设置名称。

Performs the name operation.

参数Parameters
名称Name类型Type说明Description
nameString名称(类型 `String`)。The name.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/message/UserMessage.java:115–119

content

public Builder content(List<ContentBlock> content)

设置内容。

Performs the content operation.

参数Parameters
名称Name类型Type说明Description
contentList<ContentBlock>内容(类型 `List`)。The content.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/message/UserMessage.java:121–125

content

public Builder content(ContentBlock block)

设置内容。

Performs the content operation.

参数Parameters
名称Name类型Type说明Description
blockContentBlock内容块(类型 `ContentBlock`)。The block.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/message/UserMessage.java:127–131

content

public Builder content(ContentBlock... blocks)

设置内容。

Performs the content operation.

参数Parameters
名称Name类型Type说明Description
blocks varargsContentBlock...内容块列表(类型 `ContentBlock...`)。The blocks.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/message/UserMessage.java:133–137

textContent

public Builder textContent(String text)

设置文本内容。

Performs the text content operation.

参数Parameters
名称Name类型Type说明Description
textString文本(类型 `String`)。The text.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/message/UserMessage.java:139–143

metadata

public Builder metadata(Map<String, Object> metadata)

设置元数据。

Performs the metadata operation.

参数Parameters
名称Name类型Type说明Description
metadataMap<String, Object>元数据(类型 `Map`)。The metadata.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/message/UserMessage.java:145–149

timestamp

public Builder timestamp(String timestamp)

设置时间戳。

Performs the timestamp operation.

参数Parameters
名称Name类型Type说明Description
timestampString时间戳(类型 `String`)。The timestamp.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/message/UserMessage.java:151–155

usage

public Builder usage(ChatUsage usage)

设置用量。

Performs the usage operation.

参数Parameters
名称Name类型Type说明Description
usageChatUsage用量(类型 `ChatUsage`)。The usage.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/message/UserMessage.java:157–161

generateReason

public Builder generateReason(GenerateReason reason)

设置该配置项。

Performs the generate reason operation.

参数Parameters
名称Name类型Type说明Description
reasonGenerateReason原因(类型 `GenerateReason`)。The reason.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/message/UserMessage.java:163–167

build

public UserMessage build()

构建并返回最终实例。

Creates and returns an instance.

返回Returns UserMessage
返回UserMessage。Returns user message.
源码Source io/agentscope/core/message/UserMessage.java:169–172

继承成员Inherited Members

继承自Members inherited from Builder
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.