Migrate composed PromptKit consumer

This commit is contained in:
2026-11-06 01:01:13 +00:00
parent 1e3879e880
commit 7f327758d8
5 changed files with 79 additions and 29 deletions

View File

@@ -8,18 +8,17 @@ import (
"os"
"strconv"
configkit "go.maximumdirect.net/configkit"
promptkit "go.maximumdirect.net/promptkit"
"go.maximumdirect.net/ckconfig"
"go.maximumdirect.net/ckprompt"
commandkit "go.maximumdirect.net/commandkit"
configkit "go.maximumdirect.net/configkit"
promptkit "go.maximumdirect.net/promptkit"
)
type campaign struct {
PromptID string `yaml:"prompt_id"`
PromptVersion string `yaml:"prompt_version"`
ProfileID string `yaml:"profile_id"`
Model string `yaml:"model"`
PromptID string `yaml:"prompt_id"`
ProfileID string `yaml:"profile_id"`
Model string `yaml:"model"`
}
type appConfiguration struct {
@@ -90,8 +89,8 @@ func loadApplicationConfig(ctx context.Context, selection ckconfig.Selection, in
source := configkit.Mapping("composed application settings", map[string]any{
"default_campaign": "spring",
"campaigns": map[string]any{
"spring": map[string]any{"prompt_id": "briefing", "prompt_version": "1", "profile_id": "spring", "model": "spring-model"},
"autumn": map[string]any{"prompt_id": "briefing", "prompt_version": "1", "profile_id": "autumn", "model": "autumn-model"},
"spring": map[string]any{"prompt_id": "briefing", "profile_id": "spring", "model": "spring-model"},
"autumn": map[string]any{"prompt_id": "briefing", "profile_id": "autumn", "model": "autumn-model"},
},
})
if selection.Config.Set {
@@ -128,10 +127,10 @@ func loadPromptEngine(ctx context.Context, selection ckconfig.Selection, input *
"collections": map[string]any{
"field-notes": map[string]any{
"release_version": "1",
"backends": map[string]any{"demo": map[string]any{"endpoint": "https://example.invalid/v1"}},
"profiles": map[string]any{"assistant": map[string]any{"backend": "field-notes/demo", "model": "example-model"}},
"prompts": map[string]any{"briefing": map[string]any{
"version": "1",
"backends": []any{map[string]any{"id": "demo", "endpoint": "https://example.invalid/v1"}},
"profiles": []any{map[string]any{"id": "assistant", "backend": "field-notes/demo", "model": "example-model"}},
"prompts": []any{map[string]any{
"id": "briefing",
"default_profile": "field-notes/assistant",
"inputs": []any{map[string]any{"name": "topic", "required": true, "content_type": "text/plain", "description": "Topic to brief"}},
"messages": []any{map[string]any{"role": "user", "content": "Write a concise briefing about {{.topic}}."}},
@@ -139,15 +138,18 @@ func loadPromptEngine(ctx context.Context, selection ckconfig.Selection, input *
}},
},
},
"profiles": map[string]any{chosen.ProfileID: map[string]any{
"backends": []any{map[string]any{"id": "local", "endpoint": "https://example.invalid/v1"}},
"profiles": []any{map[string]any{
"id": chosen.ProfileID,
"backend": "local",
"endpoint": "https://example.invalid/v1",
"model": chosen.Model,
"extra_params": map[string]any{
"campaign": name,
},
}},
"prompts": map[string]any{chosen.PromptID: map[string]any{
"version": chosen.PromptVersion,
"prompts": []any{map[string]any{
"id": chosen.PromptID,
"default_profile": chosen.ProfileID,
"inputs": []any{map[string]any{"name": "topic", "required": true, "content_type": "text/plain", "description": "Topic to brief"}},
"messages": []any{map[string]any{"role": "user", "content": "Write a concise briefing about {{.topic}}. {{if .mode}}{{input \"notes\"}}{{end}}"}},