类 Msg.Builder
java.lang.Object
io.agentscope.core.message.Msg.Builder
- 封闭类:
Msg
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明build()Builds a new message instance with the configured properties.content(ContentBlock block) Set content from a single content block (convenience method).content(ContentBlock... blocks) Set content from varargs content blocks (convenience method).content(List<ContentBlock> content) Set content from a list of content blocks.generateReason(GenerateReason reason) Sets the generate reason for this message.Sets the unique identifier for the message.Set metadata for structured output.Sets the optional name for the message.Sets the role for the message.textContent(String text) Set text content from a string.Sets the timestamp for the message.
-
构造器详细资料
-
Builder
public Builder()Creates a new builder with a randomly generated message ID.
-
-
方法详细资料
-
id
Sets the unique identifier for the message.- 参数:
id- The message ID- 返回:
- This builder for chaining
-
name
Sets the optional name for the message.- 参数:
name- The message name- 返回:
- This builder for chaining
-
role
Sets the role for the message.- 参数:
role- The message role (user, assistant, system, or tool)- 返回:
- This builder for chaining
-
content
Set content from a list of content blocks.- 参数:
content- List of content blocks- 返回:
- This builder
-
content
Set content from a single content block (convenience method). The block will be wrapped in a list automatically.- 参数:
block- Single content block- 返回:
- This builder
-
content
Set content from varargs content blocks (convenience method).- 参数:
blocks- Content blocks- 返回:
- This builder
-
textContent
Set text content from a string.- 参数:
text- Text content- 返回:
- This builder
-
metadata
Set metadata for structured output.- 参数:
metadata- Metadata map- 返回:
- This builder
-
timestamp
Sets the timestamp for the message.- 参数:
timestamp- The timestamp string- 返回:
- This builder for chaining
-
generateReason
Sets the generate reason for this message.The generate reason indicates why this message was generated by the agent, helping users understand the execution context and required follow-up actions.
- 参数:
reason- The generate reason- 返回:
- This builder for chaining
-
build
Builds a new message instance with the configured properties. If timestamp is not set, it will be auto-generated.- 返回:
- A new immutable message
-