Files
notarius/internal/framework/llm/promptkit_test_helpers_test.go

44 lines
1.3 KiB
Go

package llm
import (
"testing"
"testing/fstest"
configkit "gitea.maximumdirect.net/eric/ConfigKit"
"gitea.maximumdirect.net/eric/promptkit"
)
func promptKitTestString(value string) *string { return &value }
func promptKitTestInt(value int) *int { return &value }
func promptKitTestFloat(value float64) *float64 { return &value }
func promptKitTestInputs(t *testing.T, label string, files fstest.MapFS, root string) []configkit.Input {
t.Helper()
inputs, err := promptkit.FilesystemInputs(label, files, root)
if err != nil {
t.Fatalf("FilesystemInputs() error = %v", err)
}
return inputs
}
func promptKitTestSources(
backends map[string]promptkit.BackendConfig,
profiles map[string]promptkit.ProfileConfig,
otherInputs ...configkit.Input,
) promptkit.ConfigurationSources {
inputs := make([]configkit.Input, 0, len(otherInputs)+2)
if len(backends) != 0 {
inputs = append(inputs, configkit.Input{Source: promptkit.BackendSource("test backends", backends)})
}
if len(profiles) != 0 {
inputs = append(inputs, configkit.Input{Source: promptkit.ProfileSource("test profiles", profiles)})
}
inputs = append(inputs, otherInputs...)
if len(inputs) == 0 {
return promptkit.ConfigurationSources{}
}
return promptkit.ConfigurationSources{Underlays: []configkit.Underlay{{Inputs: inputs}}}
}