Construct prompt engines from shared configuration

This commit is contained in:
2026-11-23 04:23:59 +00:00
parent 1ca5011049
commit 9977cd9130
21 changed files with 153 additions and 253 deletions

View File

@@ -0,0 +1,42 @@
package llm
import (
"context"
"os"
"path/filepath"
"slices"
"testing"
"gitea.maximumdirect.net/eric/audita/v4/internal/appconfig"
ck "go.maximumdirect.net/configkit"
)
func TestRuntimeCapturesSharedSources(t *testing.T) {
root := t.TempDir()
project := filepath.Join(root, "project")
if err := os.MkdirAll(filepath.Join(project, "prompts", "nested"), 0755); err != nil {
t.Fatal(err)
}
for name, contents := range map[string]string{
"config.yml": "version: 3\n",
"prompts/nested/catalog.yml": "collections:\n sample:\n prompts:\n - id: fixture\n messages:\n - role: user\n content_file: message.txt\n output:\n format: text\n validation_mode: none\n",
"prompts/nested/message.txt": "source-local",
} {
if err := os.WriteFile(filepath.Join(project, name), []byte(contents), 0600); err != nil {
t.Fatal(err)
}
}
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(filepath.Join(project, "config.yml")), Filesystem: &ck.FilesystemContext{Root: root}}, "")
if err != nil {
t.Fatal(err)
}
runtime, err := NewRuntime(context.Background(), loaded, nil)
if err != nil {
t.Fatal(err)
}
for _, name := range []string{"config.yml", "prompts/nested/catalog.yml", "prompts/nested/message.txt"} {
if !slices.Contains(runtime.SourcePaths, filepath.Join(project, name)) {
t.Errorf("missing %s in %v", name, runtime.SourcePaths)
}
}
}