Package dev.dokimos.core.conversation
Record Class ScenarioSeed
java.lang.Object
java.lang.Record
dev.dokimos.core.conversation.ScenarioSeed
- Record Components:
scenario- the scenario description passed to the simulator and stored in metadatainitialMessage- the first user message, or empty to let the simulated user openexpectedOutcome- a natural-language completion criterion stored in the example metadata under"expectedOutcome", or null; it never stops the simulationuserTurns- the scripted user turns, in order; empty for a persona-driven seedpersonaFactory- builds the simulated user from the generator's judge, or null for a scripted seedmaxTurns- the turn limit for this seed, or null to inherit the generator's defaultexpectedOutputs- expected outputs merged into the example, overriding generated defaultsmetadata- extra metadata merged into the example
public record ScenarioSeed(String scenario, String initialMessage, String expectedOutcome, List<String> userTurns, Function<JudgeLM,SimulatedUser> personaFactory, Integer maxTurns, Map<String,Object> expectedOutputs, Map<String,Object> metadata)
extends Record
Describes one conversation for
GoldenGenerator to synthesize into a dataset example.
A seed is either scripted (a fixed list of user turns, no LLM involved) or
persona-driven (a factory that receives the generator's JudgeLM and returns a
SimulatedUser), never both and never neither. The factory is applied at generation time,
so a method reference such as UserPersonas::confusedUser works without a judge in scope.
Turn semantics: ConversationSimulator consumes initialMessage as turn 0 and only
then starts asking the simulated user for messages. A scripted seed that sets both
initialMessage and userTurns therefore continues at userTurns.get(1) on
the next turn, and userTurns.get(0) is never sent. Leave initialMessage empty (as
scripted(String, List) does) to have the script drive every turn.
Example usage:
ScenarioSeed refund = ScenarioSeed.scripted(
"Return request", List.of("I want a refund", "Order #123"));
ScenarioSeed escalation = ScenarioSeed.builder()
.scenario("Angry customer escalates")
.initialMessage("This product broke on day one!")
.personaFactory(UserPersonas::aggressiveCustomer)
.expectedOutcome("The agent apologizes and offers a replacement or refund")
.build();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for constructing scenario seeds. -
Constructor Summary
ConstructorsConstructorDescriptionScenarioSeed(String scenario, String initialMessage, String expectedOutcome, List<String> userTurns, Function<JudgeLM, SimulatedUser> personaFactory, Integer maxTurns, Map<String, Object> expectedOutputs, Map<String, Object> metadata) Normalizes nulls, copies the collections defensively, and enforces the user source invariant. -
Method Summary
Modifier and TypeMethodDescriptionstatic ScenarioSeed.Builderbuilder()Creates a new builder for constructing seeds.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theexpectedOutcomerecord component.Returns the value of theexpectedOutputsrecord component.final inthashCode()Returns a hash code value for this object.Returns the value of theinitialMessagerecord component.booleanReturns whether this seed drives its user with a persona factory rather than a script.maxTurns()Returns the value of themaxTurnsrecord component.metadata()Returns the value of themetadatarecord component.static ScenarioSeedCreates a persona-driven seed.Returns the value of thepersonaFactoryrecord component.scenario()Returns the value of thescenariorecord component.static ScenarioSeedCreates a scripted seed whose user turns are replayed verbatim, with no judge involved.final StringtoString()Returns a string representation of this record class.Returns the value of theuserTurnsrecord component.
-
Constructor Details
-
ScenarioSeed
public ScenarioSeed(String scenario, String initialMessage, String expectedOutcome, List<String> userTurns, Function<JudgeLM, SimulatedUser> personaFactory, Integer maxTurns, Map<String, Object> expectedOutputs, Map<String, Object> metadata) Normalizes nulls, copies the collections defensively, and enforces the user source invariant.- Throws:
IllegalArgumentException- if the seed sets both or neither ofuserTurnsandpersonaFactory
-
-
Method Details
-
scripted
Creates a scripted seed whose user turns are replayed verbatim, with no judge involved.- Parameters:
scenario- the scenario descriptionuserTurns- the user turns, in order, starting with the opening message- Returns:
- a new scripted seed
-
persona
public static ScenarioSeed persona(String scenario, String initialMessage, Function<JudgeLM, SimulatedUser> personaFactory) Creates a persona-driven seed. The factory is applied to the generator's judge at generation time, not when the seed is built.- Parameters:
scenario- the scenario descriptioninitialMessage- the first user message, or empty to let the persona openpersonaFactory- builds the simulated user from a judge- Returns:
- a new persona-driven seed
-
builder
Creates a new builder for constructing seeds.- Returns:
- a new builder
-
isDynamic
public boolean isDynamic()Returns whether this seed drives its user with a persona factory rather than a script.- Returns:
- true if the seed is persona-driven
-
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). -
scenario
Returns the value of thescenariorecord component.- Returns:
- the value of the
scenariorecord component
-
initialMessage
Returns the value of theinitialMessagerecord component.- Returns:
- the value of the
initialMessagerecord component
-
expectedOutcome
Returns the value of theexpectedOutcomerecord component.- Returns:
- the value of the
expectedOutcomerecord component
-
userTurns
Returns the value of theuserTurnsrecord component.- Returns:
- the value of the
userTurnsrecord component
-
personaFactory
Returns the value of thepersonaFactoryrecord component.- Returns:
- the value of the
personaFactoryrecord component
-
maxTurns
Returns the value of themaxTurnsrecord component.- Returns:
- the value of the
maxTurnsrecord component
-
expectedOutputs
Returns the value of theexpectedOutputsrecord component.- Returns:
- the value of the
expectedOutputsrecord component
-
metadata
Returns the value of themetadatarecord component.- Returns:
- the value of the
metadatarecord component
-