Add embedded weather profile catalog

This commit is contained in:
2026-08-01 14:13:11 +00:00
parent cc97ae186c
commit acbe22dcad
7 changed files with 364 additions and 816 deletions

View File

@@ -0,0 +1,6 @@
id: weather-balanced
backend: openrouter
model: "~google/gemini-flash-latest"
reasoning_effort: high
timeout_seconds: 240
service_tier: flex

View File

@@ -0,0 +1,6 @@
id: weather-deep
backend: openrouter
model: "~anthropic/claude-sonnet-latest"
reasoning_effort: high
timeout_seconds: 240
service_tier: flex

View File

@@ -0,0 +1,5 @@
id: weather-light
backend: openrouter
model: deepseek/deepseek-v4-flash
timeout_seconds: 180
service_tier: flex

View File

@@ -7,7 +7,7 @@ import (
"io/fs"
)
//go:embed assets/prompts assets/schemas
//go:embed assets/prompts assets/profiles assets/schemas
var assets embed.FS
var schemaPaths = map[string]string{
@@ -35,6 +35,15 @@ func SchemaFS() fs.FS {
return fsys
}
// ProfileFS returns the embedded Weatherreporter Promptkit profile definitions.
func ProfileFS() fs.FS {
fsys, err := fs.Sub(assets, "assets/profiles")
if err != nil {
panic(fmt.Sprintf("embedded profile assets: %v", err))
}
return fsys
}
// Schema returns an independent copy of the canonical schema for id.
func Schema(id string) ([]byte, error) {
path, ok := schemaPaths[id]

View File

@@ -140,6 +140,83 @@ func TestPromptkitInspectsEmbeddedPromptsOffline(t *testing.T) {
}
}
func TestEmbeddedProfilesAreCompleteAndInspectable(t *testing.T) {
wantPaths := map[string]bool{
"weather-balanced.yml": false,
"weather-deep.yml": false,
"weather-light.yml": false,
}
if err := fs.WalkDir(promptassets.ProfileFS(), ".", func(path string, entry fs.DirEntry, err error) error {
if err != nil || entry.IsDir() {
return err
}
if _, ok := wantPaths[path]; !ok {
t.Fatalf("unexpected embedded profile asset %q", path)
}
wantPaths[path] = true
return nil
}); err != nil {
t.Fatalf("walk embedded profiles: %v", err)
}
for path, found := range wantPaths {
if !found {
t.Errorf("missing embedded profile asset %q", path)
}
}
engine, err := promptkit.NewEngine(promptkit.Config{},
promptkit.WithPromptFS(promptassets.PromptFS(), "."),
promptkit.WithSchemaFS(promptassets.SchemaFS(), "."),
promptkit.WithFallbackProfileFS(promptassets.ProfileFS(), "."),
)
if err != nil {
t.Fatalf("NewEngine() error = %v", err)
}
profiles := []struct {
id string
model string
timeoutSeconds int
reasoningEffort string
}{
{"weather-light", "deepseek/deepseek-v4-flash", 180, ""},
{"weather-balanced", "~google/gemini-flash-latest", 240, "high"},
{"weather-deep", "~anthropic/claude-sonnet-latest", 240, "high"},
}
for _, want := range profiles {
t.Run(want.id, func(t *testing.T) {
inspection, err := engine.InspectProfile(context.Background(), want.id)
if err != nil {
t.Fatalf("InspectProfile() error = %v", err)
}
got := inspection.EffectiveModelParams
if inspection.ProfileID != want.id || got.BackendID != "openrouter" || got.Model != want.model || got.TimeoutSeconds != want.timeoutSeconds || got.ServiceTier != "flex" || got.ReasoningEffort != want.reasoningEffort {
t.Fatalf("inspection = %#v, want %q using openrouter model %q", inspection, want.id, want.model)
}
})
}
}
func TestEmbeddedProfilesExcludeUnsafeOrIncidentalSettings(t *testing.T) {
forbidden := []string{"endpoint:", "api_key", "credential", "temperature:", "top_p:", "max_tokens:"}
if err := fs.WalkDir(promptassets.ProfileFS(), ".", func(path string, entry fs.DirEntry, err error) error {
if err != nil || entry.IsDir() {
return err
}
data, err := fs.ReadFile(promptassets.ProfileFS(), path)
if err != nil {
return err
}
for _, setting := range forbidden {
if strings.Contains(string(data), setting) {
t.Fatalf("%s contains forbidden profile setting %q", path, setting)
}
}
return nil
}); err != nil {
t.Fatalf("walk embedded profiles: %v", err)
}
}
func TestPromptAssetsExcludeRetiredRuntimeSettings(t *testing.T) {
if err := fs.WalkDir(promptassets.PromptFS(), ".", func(path string, entry fs.DirEntry, err error) error {
if err != nil || entry.IsDir() {