类 AiMessage

java.lang.Object
com.ajaxjs.mcp.message.AiMessage
所有已实现的接口:
ChatMessage

public class AiMessage extends Object implements ChatMessage
Represents a response message from an AI (language model). The message can contain either a textual response or a request to execute one/multiple tool(s). In the case of tool execution, the response to this message should be one/multiple ToolExecutionResultMessage.
  • 构造器详细资料

    • AiMessage

      public AiMessage(String text)
      Create a new AiMessage with the given text.
      参数:
      text - the text of the message.
    • AiMessage

      public AiMessage(List<ToolExecutionRequest> toolExecutionRequests)
      Create a new AiMessage with the given tool execution requests.
      参数:
      toolExecutionRequests - the tool execution requests of the message.
    • AiMessage

      public AiMessage(String text, List<ToolExecutionRequest> toolExecutionRequests)
      Create a new AiMessage with the given text and tool execution requests.
      参数:
      text - the text of the message.
      toolExecutionRequests - the tool execution requests of the message.
  • 方法详细资料

    • text

      public String text()
      Get the text of the message.
      返回:
      the text of the message.
    • toolExecutionRequests

      public List<ToolExecutionRequest> toolExecutionRequests()
      Get the tool execution requests of the message.
      返回:
      the tool execution requests of the message.
    • hasToolExecutionRequests

      public boolean hasToolExecutionRequests()
      Check if the message has ToolExecutionRequests.
      返回:
      true if the message has ToolExecutionRequests, false otherwise.
    • type

      public ChatMessageType type()
      从接口复制的说明: ChatMessage
      The type of the message.
      指定者:
      type 在接口中 ChatMessage
      返回:
      the type of the message
    • builder

      public static AiMessage.Builder builder()
    • from

      public static AiMessage from(String text)
      Create a new AiMessage with the given text.
      参数:
      text - the text of the message.
      返回:
      the new AiMessage.
    • from

      public static AiMessage from(ToolExecutionRequest... toolExecutionRequests)
      Create a new AiMessage with the given tool execution requests.
      参数:
      toolExecutionRequests - the tool execution requests of the message.
      返回:
      the new AiMessage.
    • from

      public static AiMessage from(List<ToolExecutionRequest> toolExecutionRequests)
      Create a new AiMessage with the given tool execution requests.
      参数:
      toolExecutionRequests - the tool execution requests of the message.
      返回:
      the new AiMessage.
    • from

      public static AiMessage from(String text, List<ToolExecutionRequest> toolExecutionRequests)
      Create a new AiMessage with the given text and tool execution requests.
      参数:
      text - the text of the message.
      toolExecutionRequests - the tool execution requests of the message.
      返回:
      the new AiMessage.
    • aiMessage

      public static AiMessage aiMessage(String text)
      Create a new AiMessage with the given text.
      参数:
      text - the text of the message.
      返回:
      the new AiMessage.
    • aiMessage

      public static AiMessage aiMessage(ToolExecutionRequest... toolExecutionRequests)
      Create a new AiMessage with the given tool execution requests.
      参数:
      toolExecutionRequests - the tool execution requests of the message.
      返回:
      the new AiMessage.
    • aiMessage

      public static AiMessage aiMessage(List<ToolExecutionRequest> toolExecutionRequests)
      Create a new AiMessage with the given tool execution requests.
      参数:
      toolExecutionRequests - the tool execution requests of the message.
      返回:
      the new AiMessage.