Package dev.dokimos.core.conversation
Record Class ConversationTrajectory
java.lang.Object
java.lang.Record
dev.dokimos.core.conversation.ConversationTrajectory
- Record Components:
messages- the list of messages in chronological orderscenario- a description of the test scenariometadata- additional metadata about the conversation
public record ConversationTrajectory(List<Message> messages, String scenario, Map<String,Object> metadata)
extends Record
Represents a complete conversation trajectory between a simulated user and an
application.
A trajectory captures the full history of messages exchanged during a multi-turn conversation, along with scenario information and metadata for evaluation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for constructing conversation trajectories. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns only the assistant messages from the conversation.builder()Creates a new builder for constructing trajectories.static ConversationTrajectoryempty()Creates an empty trajectory with no messages.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanisEmpty()Checks if the conversation is empty.Returns the last assistant message in the conversation, if any.Returns the last message in the conversation, if any.Returns the last user message in the conversation, if any.messages()Returns the value of themessagesrecord component.metadata()Returns the value of themetadatarecord component.scenario()Returns the value of thescenariorecord component.Returns only the system messages from the conversation.toJson()Serializes the trajectory to JSON for debugging and logging.final StringtoString()Returns a string representation of this record class.toText()Formats the conversation as a simple text transcript.intReturns the number of conversation turns (user-assistant message pairs).Returns only the user messages from the conversation.withMessage(Message message) Creates a new trajectory with an additional message appended.
-
Constructor Details
-
ConversationTrajectory
Compact constructor ensuring immutability.
-
-
Method Details
-
empty
Creates an empty trajectory with no messages.- Returns:
- an empty trajectory
-
builder
Creates a new builder for constructing trajectories.- Returns:
- a new builder
-
turnCount
public int turnCount()Returns the number of conversation turns (user-assistant message pairs).A turn is counted as a user message followed by an assistant response.
- Returns:
- the number of complete turns
-
userMessages
Returns only the user messages from the conversation.- Returns:
- list of user messages
-
assistantMessages
Returns only the assistant messages from the conversation.- Returns:
- list of assistant messages
-
systemMessages
Returns only the system messages from the conversation.- Returns:
- list of system messages
-
lastMessage
Returns the last message in the conversation, if any.- Returns:
- the last message or null if empty
-
lastUserMessage
Returns the last user message in the conversation, if any.- Returns:
- the last user message or null if none
-
lastAssistantMessage
Returns the last assistant message in the conversation, if any.- Returns:
- the last assistant message or null if none
-
withMessage
Creates a new trajectory with an additional message appended.- Parameters:
message- the message to append- Returns:
- a new trajectory with the message added
-
isEmpty
public boolean isEmpty()Checks if the conversation is empty.- Returns:
- true if there are no messages
-
toText
Formats the conversation as a simple text transcript.- Returns:
- the conversation as text
-
toJson
Serializes the trajectory to JSON for debugging and logging.- Returns:
- JSON representation of the trajectory
-
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). -
messages
Returns the value of themessagesrecord component.- Returns:
- the value of the
messagesrecord component
-
scenario
Returns the value of thescenariorecord component.- Returns:
- the value of the
scenariorecord component
-
metadata
Returns the value of themetadatarecord component.- Returns:
- the value of the
metadatarecord component
-