Enum Class MsgRole

java.lang.Object
java.lang.Enum<MsgRole>
io.agentscope.core.message.MsgRole
所有已实现的接口:
Serializable, Comparable<MsgRole>, Constable

public enum MsgRole extends Enum<MsgRole>
Defines the role of a message participant in agent conversations.

This enum specifies the origin or purpose of each message in the conversation flow, enabling proper message routing, processing, and context management.

Message roles:

  • USER - Messages from human users or external inputs
  • ASSISTANT - Messages generated by AI agents or assistants
  • SYSTEM - System instructions, prompts, or configuration messages
  • TOOL - Messages containing tool execution results or responses

The role is essential for determining how messages should be processed and formatted when interacting with different LLM APIs and tool systems.

  • 枚举常量详细资料

    • USER

      public static final MsgRole USER
      User role for messages from human users or external inputs.

      These messages typically contain user questions, commands, or input data that the agent needs to process or respond to.

    • ASSISTANT

      public static final MsgRole ASSISTANT
      Assistant role for messages generated by AI agents or assistants.

      These messages contain the agent's responses, reasoning, or actions in response to user messages or system prompts.

    • SYSTEM

      public static final MsgRole SYSTEM
      System role for system instructions, prompts, or configuration messages.

      These messages typically contain setup instructions, context information, or system-level directives that guide agent behavior.

    • TOOL

      public static final MsgRole TOOL
      Tool role for messages containing tool execution results or responses.

      These messages contain the output from tool executions, including return values, error messages, or status information from external tools.

  • 方法详细资料

    • values

      public static MsgRole[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      返回:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static MsgRole valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      参数:
      name - 要返回的枚举常量的名称。
      返回:
      返回带有指定名称的枚举常量
      抛出:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - 如果参数为空值