Moderations name a judge's categories once, by name

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-04 23:03:35 +02:00
1 parent e502996198
commit d29f694aaf
2 files changed
+7 -1

No files matched your search

+1 -1
View File
@@ -172,7 +172,7 @@ func TestModerationsAreAnsweredByTheJudge(t *testing.T) {
}
_ = json.Unmarshal(rec.Body.Bytes(), &out)
if rec.Code != 200 || out.Model != "guard" || len(out.Results) != 1 || !out.Results[0].Flagged ||
!out.Results[0].Categories["indiscriminate-weapons"] {
!out.Results[0].Categories["indiscriminate-weapons"] || out.Results[0].Categories["s9"] {
t.Errorf("%d %s", rec.Code, rec.Body.String())
}
}
+6
View File
@@ -57,6 +57,12 @@ func (r *Router) handleModerations(w http.ResponseWriter, req *http.Request) {
categories[moderationKey(n)], scores[moderationKey(n)] = false, 0
}
for _, c := range cats {
// The judge says both a code and the name it stands for; the
// name is what is shown, when there is one.
var n int
if _, err := fmt.Sscanf(c, "S%d", &n); err == nil && n >= 1 && n <= len(names) {
continue
}
categories[moderationKey(c)], scores[moderationKey(c)] = true, 1
}
results = append(results, map[string]any{"flagged": unsafe, "categories": categories, "category_scores": scores})