diff --git a/internal/router/guard_test.go b/internal/router/guard_test.go index e75c238..97bdb83 100644 --- a/internal/router/guard_test.go +++ b/internal/router/guard_test.go @@ -241,3 +241,17 @@ func TestWhatTheGuardrailsDidIsCounted(t *testing.T) { t.Errorf("output blocks counted %v", n) } } + +func TestAJudgeModelIsNotNamedToClientsInErrors(t *testing.T) { + e := newFakeEngine(t, "llama-guard") + cfg := baseConfig(config.Endpoint{ID: "j", URL: e.srv.URL, Models: []string{"llama-guard"}}) + judge := catModel("llama-guard", nil) + judge.Role, judge.Guard = catalog.RoleGuard, &catalog.GuardModel{Format: "llamaguard3"} + cfg.Models = []catalog.Model{judge, catModel("absent", nil)} + rt := newTestRouter(t, cfg) + waitForEndpoint(t, rt) + rec := post(t, rt.Handler(), map[string]any{"model": "absent", "messages": []any{}}, nil) + if strings.Contains(rec.Body.String(), "llama-guard") { + t.Errorf("named: %s", rec.Body.String()) + } +} diff --git a/internal/router/router.go b/internal/router/router.go index 7ed0e11..c897c86 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -817,7 +817,7 @@ func (r *Router) dispatchOne(ctx context.Context, w http.ResponseWriter, req *pa return dispatchResult{err: fmt.Errorf("%w: %s", errLoading, "the model is loading; retry shortly")} } - return dispatchResult{err: fmt.Errorf("%w: %s", errNoCapacity, noEndpointFor(model, r.servedModels()))} + return dispatchResult{err: fmt.Errorf("%w: %s", errNoCapacity, noEndpointFor(model, slices.DeleteFunc(r.servedModels(), r.isGuardModel)))} } profile := r.profileFor(entry, req.ProfileOverride)