Class ToolMessage

java.lang.Object
nl.dannyj.mistral.models.completion.message.ChatMessage
nl.dannyj.mistral.models.completion.message.ToolMessage

public class ToolMessage extends ChatMessage
Represents a message with the 'tool' role in a chat conversation. Tool messages are used to provide the results of a tool call back to the model.
  • Constructor Details

    • ToolMessage

      public ToolMessage(@NonNull @NonNull String textContent, @Nullable String toolCallId)
      Constructs a ToolMessage with simple text content and the corresponding tool call ID.
      Parameters:
      textContent - The text content (result) of the tool call. Cannot be null.
      toolCallId - The ID of the tool call this message responds to. Can be null.
    • ToolMessage

      public ToolMessage(@NonNull @NotEmpty @NonNull @NotEmpty List<ContentChunk> contentChunks, @Nullable String toolCallId)
      Constructs a ToolMessage with potentially complex content and the corresponding tool call ID.
      Parameters:
      contentChunks - The list of content chunks representing the tool result. Cannot be null or empty.
      toolCallId - The ID of the tool call this message responds to. Can be null.
    • ToolMessage

      public ToolMessage()
  • Method Details

    • getRole

      public MessageRole getRole()
      Gets the role of this message.
      Specified by:
      getRole in class ChatMessage
      Returns:
      Always returns MessageRole.TOOL.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getToolCallId

      @Nullable public String getToolCallId()
      The ID of the tool call that this message is a response to. Can be null.
      Returns:
      The tool call ID.
    • setToolCallId

      public void setToolCallId(@Nullable String toolCallId)
      The ID of the tool call that this message is a response to. Can be null.
      Parameters:
      toolCallId - The tool call ID.
    • getName

      @Nullable public String getName()
      The name associated with the tool call. Can be null.
      Returns:
      The name.
    • setName

      public void setName(@Nullable String name)
      The name associated with the tool call. Can be null.
      Parameters:
      name - The name.