Package dev.dokimos.core.conversation
Record Class Message
java.lang.Object
java.lang.Record
dev.dokimos.core.conversation.Message
- Record Components:
role- the role of the message sendercontent- the message contentmetadata- additional metadata about the message
public record Message(Message.Role role, String content, Map<String,Object> metadata)
extends Record
Represents a single message in a conversation.
Each message has a role (USER, ASSISTANT, or SYSTEM), content, and optional metadata.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe role of a message sender in a conversation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic MessageCreates an assistant message.content()Returns the value of thecontentrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanChecks if this message is from an assistant.booleanisSystem()Checks if this message is a system message.booleanisUser()Checks if this message is from a user.metadata()Returns the value of themetadatarecord component.static Messageof(Message.Role role, String content) Creates a message with just role and content.role()Returns the value of therolerecord component.static MessageCreates a system message.final StringtoString()Returns a string representation of this record class.static MessageCreates a user message.
-
Constructor Details
-
Message
Compact constructor.
-
-
Method Details
-
of
Creates a message with just role and content.- Parameters:
role- the message rolecontent- the message content- Returns:
- a new message
-
user
Creates a user message.- Parameters:
content- the message content- Returns:
- a new user message
-
assistant
Creates an assistant message.- Parameters:
content- the message content- Returns:
- a new assistant message
-
system
Creates a system message.- Parameters:
content- the message content- Returns:
- a new system message
-
isUser
public boolean isUser()Checks if this message is from a user.- Returns:
- true if the role is USER
-
isAssistant
public boolean isAssistant()Checks if this message is from an assistant.- Returns:
- true if the role is ASSISTANT
-
isSystem
public boolean isSystem()Checks if this message is a system message.- Returns:
- true if the role is SYSTEM
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
role
Returns the value of therolerecord component.- Returns:
- the value of the
rolerecord component
-
content
Returns the value of thecontentrecord component.- Returns:
- the value of the
contentrecord component
-
metadata
Returns the value of themetadatarecord component.- Returns:
- the value of the
metadatarecord component
-