Document the library migration and update examples
This commit is contained in:
@@ -17,7 +17,9 @@ import (
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/appconfig"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/core/schema"
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/framework/llm"
|
||||
auditaprompts "gitea.maximumdirect.net/eric/audita/v4/internal/prompts"
|
||||
ck "go.maximumdirect.net/configkit"
|
||||
pk "go.maximumdirect.net/promptkit"
|
||||
)
|
||||
|
||||
func TestMaintainedProjectsWithControlledProvider(t *testing.T) {
|
||||
@@ -33,6 +35,32 @@ func TestMaintainedProjectsWithControlledProvider(t *testing.T) {
|
||||
} {
|
||||
t.Run(tc.dir+"/"+tc.main, func(t *testing.T) {
|
||||
main := filepath.Join(root, tc.dir, tc.main)
|
||||
if tc.dir == "service" {
|
||||
dir := t.TempDir()
|
||||
if err := os.Mkdir(filepath.Join(dir, "overlays"), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Mkdir(filepath.Join(dir, "secrets"), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, name := range []string{"config.yml", "prompts.yml", "overlays/testing.yml"} {
|
||||
data, err := os.ReadFile(filepath.Join(root, tc.dir, name))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if name == "config.yml" {
|
||||
data = append(data, []byte("\nconfig:\n secrets_dir: secrets\n secrets_overwrite: true\n")...)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(dir, name), data, 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(dir, "secrets", "AUDITA_EXAMPLE_KEY"), []byte("synthetic-bootstrap-key"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Setenv("AUDITA_EXAMPLE_KEY", "")
|
||||
main = filepath.Join(dir, "config.yml")
|
||||
}
|
||||
loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(main)}, tc.overlay)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -42,6 +70,9 @@ func TestMaintainedProjectsWithControlledProvider(t *testing.T) {
|
||||
var mu sync.Mutex
|
||||
var models, prompts []string
|
||||
transport := controlledTransport(func(r *http.Request) (*http.Response, error) {
|
||||
if tc.dir == "service" && r.Header.Get("Authorization") != "Bearer synthetic-bootstrap-key" {
|
||||
t.Errorf("bootstrap credential was not supplied")
|
||||
}
|
||||
calls.Add(1)
|
||||
var request struct {
|
||||
Model string `json:"model"`
|
||||
@@ -89,6 +120,12 @@ func TestMaintainedProjectsWithControlledProvider(t *testing.T) {
|
||||
if tc.dir == "service" && (len(models) != 1 || models[0] != "example-testing-model") {
|
||||
t.Fatalf("overlay models=%v", models)
|
||||
}
|
||||
if tc.dir == "prompt-edit" {
|
||||
prepared, err := engine.Engine.Prepare(context.Background(), pk.RunRequest{PromptID: auditaprompts.PromptIDModuleGrammarProposal, ProfileID: "local", Vars: auditaprompts.WithSharedVariables(map[string]string{"TranscriptDescriptionBlock": "", "GlossaryJSON": "[]", "SectionJSON": "[]"})})
|
||||
if err != nil || prepared.OutputContract.RepairAttempts != 2 || prepared.StructuredOutput == nil || len(prepared.Messages) != 2 {
|
||||
t.Fatalf("replacement contract: %+v, error=%v", prepared, err)
|
||||
}
|
||||
}
|
||||
if tc.dir == "campaigns" && tc.main == "first.yml" {
|
||||
if len(prompts) != 3 || !strings.Contains(prompts[0], `"name": "Lyra"`) || strings.Contains(prompts[0], `"name": "Shield"`) || !strings.Contains(prompts[1], `"name": "Shield"`) || strings.Contains(prompts[1], `"name": "Lyra"`) {
|
||||
t.Fatalf("campaign glossary selections: %v", prompts)
|
||||
|
||||
Reference in New Issue
Block a user