Class ToolResponseMessage

java.lang.Object
org.springframework.ai.chat.messages.AbstractMessage
org.springframework.ai.chat.messages.ToolResponseMessage
All Implemented Interfaces:
Message, Content

public class ToolResponseMessage extends AbstractMessage
The ToolResponseMessage class represents a message with a function content in a chat application.

The message content is an ordered list of MessageParts, one ToolResultPart per tool result, so a result can carry more than a string, for example media or an error flag. getResponses() is a view over the parts that keeps only the text of each result. Messages built through the legacy constructor or the ToolResponseMessage.Builder.responses(List) setter get one text-only result part per response, so existing code keeps working unchanged.

Since:
1.0.0
Author:
Christian Tzolov, Eric Bottard
  • Field Details

  • Constructor Details

    • ToolResponseMessage

      protected ToolResponseMessage(List<ToolResponseMessage.ToolResponse> responses, Map<String,Object> metadata)
    • ToolResponseMessage

      protected ToolResponseMessage(Map<String,Object> metadata, List<MessagePart> parts)
      Creates a message from an ordered list of parts. The metadata comes first because the legacy constructor already takes a list and a map in the other order and the two would otherwise have the same erasure.
      Parameters:
      metadata - the message metadata
      parts - the parts, in order
      Since:
      2.1.0
  • Method Details