Class AbstractMessage
java.lang.Object
org.springframework.ai.chat.messages.AbstractMessage
- Direct Known Subclasses:
AssistantMessage
,SystemMessage
,ToolResponseMessage
,UserMessage
The AbstractMessage class is an abstract implementation of the Message interface. It
provides a base implementation for message content, media attachments, metadata, and
message type.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The key for the message type in the metadata.protected final MessageType
The message type of the message.Additional options for the message to influence the response, not a generative map.protected final String
The content of the message. -
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractMessage
(MessageType messageType, String textContent, Map<String, Object> metadata) Create a new AbstractMessage with the given message type, text content, and metadata.protected
AbstractMessage
(MessageType messageType, org.springframework.core.io.Resource resource, Map<String, Object> metadata) Create a new AbstractMessage with the given message type, resource, and metadata. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Get the content of the message.Get the message type of the message.Get the metadata of the message.int
hashCode()
-
Field Details
-
MESSAGE_TYPE
The key for the message type in the metadata.- See Also:
-
messageType
The message type of the message. -
textContent
The content of the message. -
metadata
Additional options for the message to influence the response, not a generative map.
-
-
Constructor Details
-
AbstractMessage
Create a new AbstractMessage with the given message type, text content, and metadata.- Parameters:
messageType
- the message typetextContent
- the text contentmetadata
- the metadata
-
AbstractMessage
protected AbstractMessage(MessageType messageType, org.springframework.core.io.Resource resource, Map<String, Object> metadata) Create a new AbstractMessage with the given message type, resource, and metadata.- Parameters:
messageType
- the message typeresource
- the resourcemetadata
- the metadata
-
-
Method Details
-
getContent
Get the content of the message.- Specified by:
getContent
in interfaceContent
- Returns:
- the content of the message
-
getMetadata
Get the metadata of the message.- Specified by:
getMetadata
in interfaceContent
- Returns:
- the metadata of the message
-
getMessageType
Get the message type of the message.- Specified by:
getMessageType
in interfaceMessage
- Returns:
- the message type of the message
-
equals
-
hashCode
public int hashCode()
-