From a1805fe550e226826a8a44f192af369bf99c7548 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Sun, 23 Aug 2026 17:12:17 +0000 Subject: [PATCH] Add the Rakestrawhome Gemma profile --- docs/roadmap/implementation.md | 2 + engine_test.go | 90 +++++++++++-------- .../google/rakestrawhome-gemma-4-31b.yml | 3 + internal/profile/builtin/repository_test.go | 36 +++++++- 4 files changed, 92 insertions(+), 39 deletions(-) create mode 100644 internal/profile/builtin/assets/google/rakestrawhome-gemma-4-31b.yml diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index c7e5861..1034d7b 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -195,6 +195,8 @@ The stage is complete when the new ID resolves through the embedded catalog and ordinary engine assembly, contains no unintended request defaults, and does not alter the existing OpenRouter Gemma profile. +**Status:** Complete. + ## Stage 3: Update Canonical Documentation and Complete Validation ### Objective diff --git a/engine_test.go b/engine_test.go index f5ff1c4..35e28f4 100644 --- a/engine_test.go +++ b/engine_test.go @@ -1492,43 +1492,63 @@ func TestSelectedProfileRepositoryReadFailureMapsToProfileLoad(t *testing.T) { } func TestPrepareUsesBuiltInProfileWithoutProfileDir(t *testing.T) { - t.Setenv("OPENROUTER_API_KEY", "test-key") - engine, err := promptkit.NewEngine(promptkit.Config{ - PromptDir: frameworkPromptDir, - SchemaDir: frameworkSchemaDir, - }) - if err != nil { - t.Fatalf("expected engine construction to succeed, got %v", err) + tests := []struct { + name string + profileID string + backendID string + endpoint string + apiKeyEnv string + model string + }{ + { + name: "OpenRouter", + profileID: "mistral-small-3", + backendID: promptkit.BackendOpenRouter, + endpoint: "https://openrouter.ai/api/v1", + apiKeyEnv: "OPENROUTER_API_KEY", + model: "mistralai/mistral-small-3.2-24b-instruct", + }, + { + name: "Rakestrawhome", + profileID: "rakestrawhome-gemma-4-31b", + backendID: promptkit.BackendRakestrawHome, + endpoint: "https://inference.ai.rakestrawhome.com/v1", + apiKeyEnv: "RAKESTRAWHOME_INFERENCE_API_KEY", + model: "google/gemma-4-31b-it", + }, } - prepared, err := engine.Prepare(context.Background(), promptkit.RunRequest{ - PromptID: frameworkMarkdownSummaryPromptID, - ProfileID: "mistral-small-3", - Inputs: map[string]promptkit.ArtifactRef{ - "transcript": promptkit.Inline("Rin opens the gate."), - "glossary": promptkit.Inline("gate: A guarded passage."), - }, - }) - if err != nil { - t.Fatalf("expected built-in profile prepare to succeed, got %v", err) - } - if prepared.SelectedProfileID != "mistral-small-3" { - t.Fatalf("unexpected selected profile: %q", prepared.SelectedProfileID) - } - if prepared.SelectedBackendID != promptkit.BackendOpenRouter { - t.Fatalf("unexpected selected backend: %q", prepared.SelectedBackendID) - } - if prepared.EffectiveModelParams.BackendID != promptkit.BackendOpenRouter { - t.Fatalf("unexpected effective backend: %q", prepared.EffectiveModelParams.BackendID) - } - if prepared.EffectiveModelParams.Endpoint != "https://openrouter.ai/api/v1" { - t.Fatalf("unexpected built-in endpoint: %q", prepared.EffectiveModelParams.Endpoint) - } - if prepared.EffectiveModelParams.APIKeyEnv != "OPENROUTER_API_KEY" { - t.Fatalf("unexpected built-in api key environment name: %q", prepared.EffectiveModelParams.APIKeyEnv) - } - if prepared.EffectiveModelParams.Model != "mistralai/mistral-small-3.2-24b-instruct" { - t.Fatalf("unexpected built-in model: %q", prepared.EffectiveModelParams.Model) + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + t.Setenv(tc.apiKeyEnv, "test-key") + engine, err := promptkit.NewEngine(promptkit.Config{ + PromptDir: frameworkPromptDir, + SchemaDir: frameworkSchemaDir, + }) + if err != nil { + t.Fatalf("expected engine construction to succeed, got %v", err) + } + + prepared, err := engine.Prepare(context.Background(), promptkit.RunRequest{ + PromptID: frameworkMarkdownSummaryPromptID, + ProfileID: tc.profileID, + Inputs: map[string]promptkit.ArtifactRef{ + "transcript": promptkit.Inline("Rin opens the gate."), + "glossary": promptkit.Inline("gate: A guarded passage."), + }, + }) + if err != nil { + t.Fatalf("expected built-in profile prepare to succeed, got %v", err) + } + if prepared.SelectedProfileID != tc.profileID || + prepared.SelectedBackendID != tc.backendID || + prepared.EffectiveModelParams.BackendID != tc.backendID || + prepared.EffectiveModelParams.Endpoint != tc.endpoint || + prepared.EffectiveModelParams.APIKeyEnv != tc.apiKeyEnv || + prepared.EffectiveModelParams.Model != tc.model { + t.Fatalf("unexpected built-in preparation: %#v", prepared) + } + }) } } diff --git a/internal/profile/builtin/assets/google/rakestrawhome-gemma-4-31b.yml b/internal/profile/builtin/assets/google/rakestrawhome-gemma-4-31b.yml new file mode 100644 index 0000000..d81fe5e --- /dev/null +++ b/internal/profile/builtin/assets/google/rakestrawhome-gemma-4-31b.yml @@ -0,0 +1,3 @@ +id: rakestrawhome-gemma-4-31b +backend: rakestrawhome +model: google/gemma-4-31b-it diff --git a/internal/profile/builtin/repository_test.go b/internal/profile/builtin/repository_test.go index 6293129..b374c0f 100644 --- a/internal/profile/builtin/repository_test.go +++ b/internal/profile/builtin/repository_test.go @@ -26,8 +26,8 @@ func TestBuiltInProfilesValidateThroughRepository(t *testing.T) { if p.ID != id { t.Fatalf("expected profile id %q, got %q", id, p.ID) } - if p.BackendID != backend.OpenRouterID { - t.Fatalf("expected profile %q to select %q, got %q", id, backend.OpenRouterID, p.BackendID) + if !builtInBackendIDs[p.BackendID] { + t.Fatalf("expected profile %q to select a maintained built-in, got %q", id, p.BackendID) } if p.Endpoint != "" || p.APIKeyEnv != "" { t.Fatalf("expected profile %q to inherit backend connection settings, got endpoint=%q api_key_env=%q", id, p.Endpoint, p.APIKeyEnv) @@ -40,6 +40,33 @@ func TestBuiltInProfilesDoNotContainDuplicateIDsOrRawAPIKeys(t *testing.T) { loadBuiltInProfileIDs(t) } +func TestRakestrawhomeGemmaProfileUsesNativeDefaults(t *testing.T) { + p, err := NewRepository().GetProfile(context.Background(), "rakestrawhome-gemma-4-31b") + if err != nil { + t.Fatalf("load Rakestrawhome Gemma profile: %v", err) + } + if p.ID != "rakestrawhome-gemma-4-31b" || + p.BackendID != backend.RakestrawHomeID || + p.Model != "google/gemma-4-31b-it" || + p.Endpoint != "" || + p.Temperature != 0 || + p.MaxTokens != 0 || + p.TopP != 0 || + p.TimeoutSeconds != 0 || + p.ServiceTier != "" || + p.ReasoningEffort != "" || + p.APIKeyEnv != "" || + p.APIKeyRequired || + p.ExtraParams != nil { + t.Fatalf("unexpected Rakestrawhome Gemma profile: %#v", p) + } +} + +var builtInBackendIDs = map[string]bool{ + backend.OpenRouterID: true, + backend.RakestrawHomeID: true, +} + func loadBuiltInProfileIDs(t *testing.T) map[string]string { t.Helper() @@ -64,8 +91,9 @@ func loadBuiltInProfileIDs(t *testing.T) map[string]string { if _, ok := raw["api_key"]; ok { t.Fatalf("built-in profile %s contains raw api_key", name) } - if raw["backend"] != backend.OpenRouterID { - t.Fatalf("built-in profile %s does not select %q", name, backend.OpenRouterID) + backendID, ok := raw["backend"].(string) + if !ok || !builtInBackendIDs[backendID] { + t.Fatalf("built-in profile %s does not select a maintained built-in: %#v", name, raw["backend"]) } if _, ok := raw["endpoint"]; ok { t.Fatalf("built-in profile %s repeats endpoint", name)