Prototype ConfigKit and PromptKit adoption and record the findings
This commit is contained in:
42
examples/library-adoption/prompts_test.go
Normal file
42
examples/library-adoption/prompts_test.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/internal/framework/responseschema"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/prompts"
|
||||
pk "gitea.maximumdirect.net/eric/promptkit"
|
||||
)
|
||||
|
||||
func TestRealPromptRenderingParity(t *testing.T) {
|
||||
r := testRuntime(t, demonstrationClient().Transport)
|
||||
vars := roleVars()
|
||||
vars["TranscriptDescriptionBlock"] = "Transcript description:\nSynthetic context\n\n"
|
||||
for _, pair := range []struct{ id, profile string }{{"modules.grammar.proposal", "proposal"}, {"validators.grammar_review", "assessment"}} {
|
||||
system, user, _, err := prompts.RenderUserSystem(pair.id, vars)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
prepared, err := r.Engine.Prepare(context.Background(), pk.RunRequest{PromptID: pair.id, ProfileID: pair.profile, Vars: vars, APIKey: "synthetic-test-secret"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(prepared.Messages) != 2 || prepared.Messages[0].Content != system || prepared.Messages[1].Content != user {
|
||||
t.Fatalf("adapted prompt differs from Audita v1.1.0: %s", pair.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSchemaFixturesMatchAudita(t *testing.T) {
|
||||
for file, key := range map[string]responseschema.Key{"correction_set.v1.json": responseschema.CorrectionSetKey, "validator_decision_set.v1.json": responseschema.ValidatorDecisionSetKey} {
|
||||
fixture, err := assets.ReadFile("schemas/" + file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !bytes.Equal(fixture, responseschema.MustLookup(key).JSONSchema) {
|
||||
t.Fatalf("schema differs: %s", file)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user