Package dev.dokimos.core.conversation
Class GoldenGenerator
java.lang.Object
dev.dokimos.core.conversation.GoldenGenerator
Turns
ScenarioSeeds into a Dataset of synthetic multi-turn goldens by running each
seed through ConversationSimulator against the application under test.
Each seed yields one example: the rendered transcript under inputs["input"], the scenario
and turn count in metadata, and a golden-<index> dataset item id. The result is serialized
with toJson() or toJsonl() into the shape Dataset.fromJson and
Dataset.fromJsonl read, so generated goldens feed @DatasetSource directly.
Generation is stateless: every call to generate() re-runs the seeds.
Example usage:
GoldenGenerator generator = GoldenGenerator.builder()
.application(myApp)
.name("support-goldens")
.seed(ScenarioSeed.scripted("Return request", List.of("I want a refund", "Order #123")))
.build();
generator.write(Path.of("src/test/resources/datasets/support-goldens.json"));
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for constructing golden generators. -
Method Summary
Modifier and TypeMethodDescriptionstatic GoldenGenerator.Builderbuilder()Creates a new builder for constructing a golden generator.generate()Runs every seed and collects the resulting conversations into a dataset.toJson()Generates the goldens and serializes them as pretty-printed JSON in the dataset format.toJsonl()Generates the goldens and serializes them as JSONL, one example per line.voidGenerates the goldens and writes them to a JSON file, creating parent directories as needed.voidwriteJsonl(Path path) Generates the goldens and writes them to a JSONL file, creating parent directories as needed.
-
Method Details
-
builder
Creates a new builder for constructing a golden generator.- Returns:
- a new builder
-
generate
Runs every seed and collects the resulting conversations into a dataset.A seed that fails still yields an example, carrying
erroranderrorSourcein its metadata. A failure during the conversation keeps the turns gathered so far; a failure before it starts yields an example with no turns.- Returns:
- the generated dataset, one example per seed, in seed order
- Throws:
IllegalStateException- if a persona-driven seed is present and no judge was supplied
-
toJson
Generates the goldens and serializes them as pretty-printed JSON in the dataset format.- Returns:
- the dataset as JSON
-
toJsonl
Generates the goldens and serializes them as JSONL, one example per line.- Returns:
- the examples as JSONL
-
write
Generates the goldens and writes them to a JSON file, creating parent directories as needed.- Parameters:
path- the file to write- Throws:
UncheckedIOException- if writing fails
-
writeJsonl
Generates the goldens and writes them to a JSONL file, creating parent directories as needed.- Parameters:
path- the file to write- Throws:
UncheckedIOException- if writing fails
-