Package com.tnsai.session
Record Class ConversationTurn
java.lang.Object
java.lang.Record
com.tnsai.session.ConversationTurn
public record ConversationTurn(String id, Instant timestamp, TurnType type, String role, String content, Map<String,Object> metadata)
extends Record
Represents a single turn in an agent conversation.
A turn can be a user message, assistant response, tool call, or tool result.
- Author:
- TnsAI Team
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ConversationTurnCreates an assistant message turn.content()Returns the value of thecontentrecord component.static ConversationTurnCreates a turn with minimal parameters.static ConversationTurnCreates a turn with metadata.final booleanIndicates whether some other object is "equal to" this one.getMetadataValue(String key) Gets a metadata value.Gets the tool name if this is a tool-related turn.final inthashCode()Returns a hash code value for this object.booleanhasMetadata(String key) Checks if this turn has a specific metadata key.id()Returns the value of theidrecord component.metadata()Returns the value of themetadatarecord component.role()Returns the value of therolerecord component.static ConversationTurnCreates a system message turn.Returns the value of thetimestamprecord component.static ConversationTurnCreates a tool call turn.static ConversationTurntoolResult(String toolName, String result) Creates a tool result turn.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.static ConversationTurnCreates a user message turn.
-
Constructor Details
-
Method Details
-
create
Creates a turn with minimal parameters. -
create
public static ConversationTurn create(TurnType type, String role, String content, Map<String, Object> metadata) Creates a turn with metadata. -
user
Creates a user message turn. -
assistant
Creates an assistant message turn. -
system
Creates a system message turn. -
toolCall
Creates a tool call turn. -
toolResult
Creates a tool result turn. -
getMetadataValue
Gets a metadata value. -
hasMetadata
Checks if this turn has a specific metadata key. -
getToolName
Gets the tool name if this is a tool-related turn. -
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). -
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
timestamp
Returns the value of thetimestamprecord component.- Returns:
- the value of the
timestamprecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
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
-