Class UserMessage

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

public class UserMessage extends AbstractMessage implements MediaContent
A message of the type 'user' passed as input Messages with the user role are from the end-user or developer. They represent questions, prompts, or any input that you want the generative to respond to.

The message content is an ordered list of MessageParts, inherited from AbstractMessage so that it is shared with AssistantMessage. getMedia() is a view over that list, selecting the MediaParts in part order.

  • Field Details

    • media

      @Deprecated(since="2.1.0", forRemoval=true) protected final List<Media> media
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 2.1.0 in favor of getMedia(); kept so existing subclasses that read the field keep compiling. Will be removed in a future release.
      The media of this message, derived from its MediaParts.
  • Constructor Details

    • UserMessage

      public UserMessage(@Nullable String textContent)
    • UserMessage

      public UserMessage(org.springframework.core.io.Resource resource)
    • UserMessage

      protected UserMessage(List<MessagePart> parts, Map<String,Object> metadata)
      Creates a message from an ordered list of parts. A message without a TextPart (for example media only) has an empty text.
      Parameters:
      parts - the parts, in order
      metadata - the message metadata
      Since:
      2.1.0
  • Method Details