Package dev.dokimos.core.conversation
Class ConversationSimulator.Builder
java.lang.Object
dev.dokimos.core.conversation.ConversationSimulator.Builder
- Enclosing class:
ConversationSimulator
Builder for constructing conversation simulators.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplication(ConversationalApplication application) Sets the application under test.build()Builds the conversation simulator.initialMessage(String initialMessage) Sets the initial user message to start the conversation.maxTurns(int maxTurns) Sets the maximum number of conversation turns.Sets the scenario description for the conversation.simulatedUser(SimulatedUser simulatedUser) Sets the simulated user for the conversation.stoppingCondition(Predicate<ConversationTrajectory> stoppingCondition) Sets a stopping condition for early termination.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
simulatedUser
Sets the simulated user for the conversation.- Parameters:
simulatedUser- the simulated user- Returns:
- this builder
-
application
Sets the application under test.- Parameters:
application- the application to test- Returns:
- this builder
-
maxTurns
Sets the maximum number of conversation turns.A turn consists of one user message followed by one assistant response. Default is 10.
- Parameters:
maxTurns- the maximum number of turns- Returns:
- this builder
-
scenario
Sets the scenario description for the conversation.The scenario provides context to the simulated user about what kind of interaction to simulate.
- Parameters:
scenario- the scenario description- Returns:
- this builder
-
initialMessage
Sets the initial user message to start the conversation.If not set, the simulated user will generate the first message.
- Parameters:
initialMessage- the first user message- Returns:
- this builder
-
stoppingCondition
public ConversationSimulator.Builder stoppingCondition(Predicate<ConversationTrajectory> stoppingCondition) Sets a stopping condition for early termination.The simulation will stop if this predicate returns true after any message (user or assistant). This is useful for detecting when a conversation goal has been achieved.
Example:
.stoppingCondition(trajectory -> { Message last = trajectory.lastAssistantMessage(); return last != null && last.content().contains("goodbye"); })- Parameters:
stoppingCondition- the stopping condition predicate- Returns:
- this builder
-
build
Builds the conversation simulator.- Returns:
- a new conversation simulator
- Throws:
IllegalStateException- if required fields are not set
-