feat(guards): judge calls record their payload and response, and the OpenAI Decisions API is a judge backend
publish / publish (push) Successful in 1m18s

This commit is contained in:
sam committed 2026-11-16 12:04:37 +11:00
1 parent 3091e4f557
commit eeb00bbcc0
27 files changed
+2230 -99

No files matched your search

+6 -4
View File
@@ -1,9 +1,11 @@
// eval measures the policy guard's judge on the labelled cases and writes the
// result the guard reads at start. Run it from guards/policy:
//
// go run ./cmd/eval -base <System One base URL> -model <model> -out eval_result.json
// go run ./cmd/eval -api systemone -base <base URL> -model <model> -out eval_result.json
// go run ./cmd/eval -api openai-decisions -model gpt-6-luna -out eval_result.openai-decisions.json
//
// The API key, when the endpoint needs one, is read from POLICY_JUDGE_API_KEY.
// The API key is read from POLICY_JUDGE_API_KEY for systemone and from
// OPENAI_API_KEY for openai-decisions.
// The positive class is an action that breaks the policy.
package main
@@ -15,7 +17,6 @@ import (
"github.com/samcharles93/archipelago/guards/policy/internal/judge"
"github.com/samcharles93/archipelago/sdk/judgegate"
"github.com/samcharles93/archipelago/sdk/systemone"
)
var threshold = judgegate.Threshold{
@@ -71,13 +72,14 @@ func load(path string) ([]evalCase, error) {
return f.Cases, nil
}
func judgeCase(ctx context.Context, client systemone.Client, c evalCase) (judgegate.Graded, error) {
func judgeCase(ctx context.Context, client judgegate.Client, c evalCase) (judgegate.Graded, error) {
g := judgegate.Graded{ID: c.ID, Label: c.Label, Want: c.Label == judge.Violates}
j, err := judge.New(client, c.rules, judge.DefaultMinConfidence)
if err != nil {
return g, err
}
out, err := j.Assess(ctx, c.Action)
g = out.Call.Attach(g)
if err != nil {
return g, err
}