Add Promptkit-owned profile definitions

This commit is contained in:
2026-09-22 12:23:07 +00:00
parent 4c3828857c
commit ba1e85a805
8 changed files with 262 additions and 11 deletions

View File

@@ -1203,6 +1203,105 @@ func TestFallbackProfileSourcePrecedence(t *testing.T) {
})
}
func TestPromptkitOwnedProfilesUseExistingProfileWorkflows(t *testing.T) {
const (
standardID = "promptkit-openrouter-standard"
autoID = "promptkit-openrouter-auto"
)
t.Run("inspection and preparation resolve both names", func(t *testing.T) {
engine, err := promptkit.NewEngine(promptkit.Config{},
promptkit.WithPromptFS(contractPromptFS("prompt", standardID, "message"), "."),
)
if err != nil {
t.Fatalf("construct engine: %v", err)
}
for _, profileID := range []string{standardID, autoID} {
inspection, err := engine.InspectProfile(context.Background(), profileID)
if err != nil {
t.Fatalf("inspect %q: %v", profileID, err)
}
prepared, err := engine.Prepare(context.Background(), promptkit.RunRequest{
PromptID: "prompt",
ProfileID: profileID,
APIKey: "test-key",
})
if err != nil {
t.Fatalf("prepare %q: %v", profileID, err)
}
if inspection.ProfileID != profileID ||
inspection.EffectiveModelParams.BackendID != promptkit.BackendOpenRouter ||
prepared.SelectedProfileID != profileID ||
prepared.SelectedBackendID != promptkit.BackendOpenRouter ||
!reflect.DeepEqual(prepared.EffectiveModelParams, inspection.EffectiveModelParams) {
t.Fatalf("inspection and preparation differ for %q: inspection=%#v prepared=%#v", profileID, inspection, prepared)
}
}
})
t.Run("consumer definitions override an owned profile and its base", func(t *testing.T) {
auto, err := promptkit.NewEngine(promptkit.Config{},
promptkit.WithPromptFS(contractPromptFS("auto", autoID, "message"), "."),
promptkit.WithProfiles(promptkit.Profile{
ID: autoID,
Endpoint: "http://consumer.example/v1",
Model: "consumer-auto-model",
}),
)
if err != nil {
t.Fatalf("construct override engine: %v", err)
}
autoPrepared, err := auto.Prepare(context.Background(), promptkit.RunRequest{PromptID: "auto"})
if err != nil {
t.Fatalf("prepare overridden profile: %v", err)
}
if autoPrepared.EffectiveModelParams.Model != "consumer-auto-model" {
t.Fatalf("owned profile override model = %q", autoPrepared.EffectiveModelParams.Model)
}
standard, err := promptkit.NewEngine(promptkit.Config{},
promptkit.WithPromptFS(contractPromptFS("standard", standardID, "message"), "."),
promptkit.WithProfiles(promptkit.Profile{
ID: "gemini-flash-latest",
Endpoint: "http://consumer.example/v1",
Model: "consumer-base-model",
}),
)
if err != nil {
t.Fatalf("construct inherited override engine: %v", err)
}
standardPrepared, err := standard.Prepare(context.Background(), promptkit.RunRequest{PromptID: "standard"})
if err != nil {
t.Fatalf("prepare profile with overridden base: %v", err)
}
if standardPrepared.EffectiveModelParams.Model != "consumer-base-model" {
t.Fatalf("owned profile base override model = %q", standardPrepared.EffectiveModelParams.Model)
}
})
t.Run("prompt default selection remains explicit", func(t *testing.T) {
engine, err := promptkit.NewEngine(promptkit.Config{},
promptkit.WithPromptFS(contractPromptFS("default", "application-default", "message"), "."),
promptkit.WithProfiles(promptkit.Profile{
ID: "application-default",
Endpoint: "http://consumer.example/v1",
Model: "consumer-default-model",
}),
)
if err != nil {
t.Fatalf("construct default engine: %v", err)
}
prepared, err := engine.Prepare(context.Background(), promptkit.RunRequest{PromptID: "default"})
if err != nil {
t.Fatalf("prepare default profile: %v", err)
}
if prepared.SelectedProfileID != "application-default" {
t.Fatalf("selected default profile = %q", prepared.SelectedProfileID)
}
})
}
func TestFallbackProfileSourcePreservesLazyLoadingAndErrors(t *testing.T) {
const profileID = "application-profile"