类 Msg.Builder

java.lang.Object
io.agentscope.core.message.Msg.Builder
封闭类:
Msg

public static class Msg.Builder extends Object
  • 构造器详细资料

    • Builder

      public Builder()
      Creates a new builder with a randomly generated message ID.
  • 方法详细资料

    • id

      public Msg.Builder id(String id)
      Sets the unique identifier for the message.
      参数:
      id - The message ID
      返回:
      This builder for chaining
    • name

      public Msg.Builder name(String name)
      Sets the optional name for the message.
      参数:
      name - The message name
      返回:
      This builder for chaining
    • role

      public Msg.Builder role(MsgRole role)
      Sets the role for the message.
      参数:
      role - The message role (user, assistant, system, or tool)
      返回:
      This builder for chaining
    • content

      public Msg.Builder content(List<ContentBlock> content)
      Set content from a list of content blocks.
      参数:
      content - List of content blocks
      返回:
      This builder
    • content

      public Msg.Builder content(ContentBlock block)
      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

      public Msg.Builder content(ContentBlock... blocks)
      Set content from varargs content blocks (convenience method).
      参数:
      blocks - Content blocks
      返回:
      This builder
    • textContent

      public Msg.Builder textContent(String text)
      Set text content from a string.
      参数:
      text - Text content
      返回:
      This builder
    • metadata

      public Msg.Builder metadata(Map<String,Object> metadata)
      Set metadata for structured output.
      参数:
      metadata - Metadata map
      返回:
      This builder
    • timestamp

      public Msg.Builder timestamp(String timestamp)
      Sets the timestamp for the message.
      参数:
      timestamp - The timestamp string
      返回:
      This builder for chaining
    • generateReason

      public Msg.Builder generateReason(GenerateReason reason)
      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

      public Msg build()
      Builds a new message instance with the configured properties. If timestamp is not set, it will be auto-generated.
      返回:
      A new immutable message