Class UserMessage
java.lang.Object
org.springframework.ai.chat.messages.AbstractMessage
org.springframework.ai.chat.messages.UserMessage
- All Implemented Interfaces:
Message,Content,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.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionDeprecated, for removal: This API element is subject to removal in a future version.Fields inherited from class org.springframework.ai.chat.messages.AbstractMessage
MESSAGE_TYPE, messageType, metadata, textContent -
Constructor Summary
ConstructorsModifierConstructorDescriptionUserMessage(@Nullable String textContent) protectedUserMessage(List<MessagePart> parts, Map<String, Object> metadata) Creates a message from an ordered list of parts.UserMessage(org.springframework.core.io.Resource resource) -
Method Summary
Methods inherited from class org.springframework.ai.chat.messages.AbstractMessage
equals, getMessageType, getMetadata, getParts, getText, hashCode, legacyParts, selectMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.ai.content.Content
getMetadata, getText
-
Field Details
-
media
Deprecated, for removal: This API element is subject to removal in a future version.since 2.1.0 in favor ofgetMedia(); kept so existing subclasses that read the field keep compiling. Will be removed in a future release.The media of this message, derived from itsMediaParts.
-
-
Constructor Details
-
UserMessage
-
UserMessage
public UserMessage(org.springframework.core.io.Resource resource) -
UserMessage
Creates a message from an ordered list of parts. A message without aTextPart(for example media only) has an empty text.- Parameters:
parts- the parts, in ordermetadata- the message metadata- Since:
- 2.1.0
-
-
Method Details
-
toString
-
getMedia
Description copied from interface:MediaContentGet the media associated with the content.- Specified by:
getMediain interfaceMediaContent
-
copy
-
mutate
A builder pre-populated with this message's parts and metadata. CallingUserMessage.Builder.text(String)orUserMessage.Builder.media(List)on it replaces the corresponding parts, so rewriting the question keeps the media and vice versa. -
builder
-
getMedia(); kept so existing subclasses that read the field keep compiling.