枚举类 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()
      返回包含该枚举类的常量的数组, 顺序与声明这些常量的顺序相同
      返回:
      包含该枚举类的常量的数组,顺序与声明这些常量的顺序相同
    • valueOf

      public static MsgRole valueOf(String name)
      返回带有指定名称的该类的枚举常量。 字符串必须与用于声明该类的枚举常量的 标识符完全匹配。(不允许有多余 的空格字符。)
      参数:
      name - 要返回的枚举常量的名称。
      返回:
      返回带有指定名称的枚举常量
      抛出:
      IllegalArgumentException - 如果该枚举类没有带有指定名称的常量
      NullPointerException - 如果参数为空值