Judge an answer with Llama Guard 3's own prompt, as a completion, not a conversation ending on the answer
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
742d6633e2
commit
dbcecd1e85
4 files changed
+77
-15
No files matched your search
@@ -221,7 +221,7 @@ func TestAJudgeModelIsNobodysToAskButTheGuardrails(t *testing.T) {
|
||||
t.Errorf("listed: %s", rec.Body.String())
|
||||
}
|
||||
calls := e.calls.Load()
|
||||
out, err := rt.Judge(t.Context(), "llama-guard", []byte(`{"model":"llama-guard","messages":[{"role":"user","content":"x"}]}`))
|
||||
out, err := rt.Judge(t.Context(), "llama-guard", "/v1/chat/completions", []byte(`{"model":"llama-guard","messages":[{"role":"user","content":"x"}]}`))
|
||||
if err != nil || !strings.Contains(string(out), `"hi"`) || e.calls.Load() != calls+1 {
|
||||
t.Errorf("the guardrails asking: %s %v", out, err)
|
||||
}
|
||||
|
||||
@@ -15,12 +15,15 @@ import (
|
||||
// judge. It goes past admission — a judge call queued behind the tenants it
|
||||
// is judging would wait on them — and past accounting and the guardrails
|
||||
// themselves, but through the scheduler and the replicas like any request.
|
||||
func (r *Router) Judge(ctx context.Context, model string, body []byte) ([]byte, error) {
|
||||
hreq, err := http.NewRequestWithContext(ctx, http.MethodPost, "/v1/chat/completions", bytes.NewReader(body))
|
||||
func (r *Router) Judge(ctx context.Context, model, path string, body []byte) ([]byte, error) {
|
||||
if path != "/v1/chat/completions" && path != "/v1/completions" {
|
||||
return nil, fmt.Errorf("a judge is asked at /v1/chat/completions or /v1/completions, not %s", path)
|
||||
}
|
||||
hreq, err := http.NewRequestWithContext(ctx, http.MethodPost, path, bytes.NewReader(body))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := r.parse(hreq, "/v1/chat/completions")
|
||||
req, err := r.parse(hreq, path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user