Make public options opaque
This commit is contained in:
@@ -1378,6 +1378,45 @@ func TestSourceOptionsRejectInvalidInputs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPackageOptionsComposeFromSlice(t *testing.T) {
|
||||
fake := &fakeLLMClient{response: &scriptorium.GenerateResponse{Content: "ok"}}
|
||||
options := []scriptorium.Option{
|
||||
nil,
|
||||
scriptorium.WithProfiles(scriptorium.Profile{
|
||||
ID: "slice-profile",
|
||||
Endpoint: "http://slice/v1",
|
||||
Model: "slice-model",
|
||||
}),
|
||||
scriptorium.WithLLMClient(fake),
|
||||
}
|
||||
|
||||
engine, err := scriptorium.NewEngine(scriptorium.Config{
|
||||
PromptDir: "./examples/prompts",
|
||||
SchemaDir: "./examples/schemas",
|
||||
}, options...)
|
||||
if err != nil {
|
||||
t.Fatalf("expected package-provided options to compose, got %v", err)
|
||||
}
|
||||
|
||||
_, err = engine.Run(context.Background(), scriptorium.RunRequest{
|
||||
PromptID: "generic.markdown_summary",
|
||||
ProfileID: "slice-profile",
|
||||
Inputs: map[string]scriptorium.ArtifactRef{
|
||||
"transcript": scriptorium.Inline("Rin opens the gate."),
|
||||
"glossary": scriptorium.Inline("gate: A guarded passage."),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("expected run with composed options to succeed, got %v", err)
|
||||
}
|
||||
if len(fake.requests) != 1 {
|
||||
t.Fatalf("expected one generate request, got %d", len(fake.requests))
|
||||
}
|
||||
if fake.requests[0].Target.Model != "slice-model" {
|
||||
t.Fatalf("expected profile from composed options, got %q", fake.requests[0].Target.Model)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtraParamsTypedNestedValuesAreCopiedAcrossPublicBoundary(t *testing.T) {
|
||||
fake := &fakeLLMClient{response: &scriptorium.GenerateResponse{Content: "ok"}}
|
||||
engine := newExampleEngineWithOptions(t, "./examples/schemas", scriptorium.WithLLMClient(fake))
|
||||
|
||||
Reference in New Issue
Block a user