42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
// Package promptkitfixture provides small native configuration sources for
|
|
// tests that prepare registered prompt assets.
|
|
package promptkitfixture
|
|
|
|
import (
|
|
"testing"
|
|
|
|
configkit "gitea.maximumdirect.net/eric/ConfigKit"
|
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
|
"gitea.maximumdirect.net/eric/promptkit"
|
|
)
|
|
|
|
func String(value string) *string { return &value }
|
|
|
|
func AddProfiles(sources promptkit.ConfigurationSources, profiles map[string]promptkit.ProfileConfig) promptkit.ConfigurationSources {
|
|
if len(profiles) == 0 {
|
|
return sources
|
|
}
|
|
sources.Underlays = append(sources.Underlays, configkit.Underlay{Inputs: []configkit.Input{{
|
|
Source: promptkit.ProfileSource("test profiles", profiles),
|
|
}}})
|
|
return sources
|
|
}
|
|
|
|
func Profile(endpoint, model string) promptkit.ProfileConfig {
|
|
return promptkit.ProfileConfig{Endpoint: String(endpoint), Model: String(model)}
|
|
}
|
|
|
|
func NewEngine(t testing.TB, registry *llm.AssetRegistry, cfg promptkit.Config, profiles map[string]promptkit.ProfileConfig) *promptkit.Engine {
|
|
t.Helper()
|
|
sources, options, err := registry.PromptKitConfigurationSources()
|
|
if err != nil {
|
|
t.Fatalf("PromptKitConfigurationSources() error = %v", err)
|
|
}
|
|
cfg.Sources = AddProfiles(sources, profiles)
|
|
engine, err := promptkit.NewEngine(cfg, options...)
|
|
if err != nil {
|
|
t.Fatalf("NewEngine() error = %v", err)
|
|
}
|
|
return engine
|
|
}
|