guardian

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package guardian provides a deterministic content-safety model for the guardrail policies that ask an OpenAI-compatible chat model for a verdict: NeMo Guard Content Safety and Granite Guardian.

The verdict is driven by keywords in the text under review, so a scenario chooses the outcome by what it sends:

UNSAFE_USER      the user turn is unsafe (NeMo Guard "User Safety")
UNSAFE_RESPONSE  the agent turn is unsafe (NeMo Guard "Response Safety")
UNSAFE           Granite Guardian detects the configured risk
GUARDIAN_DOWN    the model fails (503), as an unavailable safety service does

NeMo Guard sends both turns in one prompt, so its two keywords are distinct: each check reads only its own verdict.

Index

Constants

View Source
const (
	UnsafeUser     = "UNSAFE_USER"
	UnsafeResponse = "UNSAFE_RESPONSE"
	Unsafe         = "UNSAFE"
	// Down makes the request fail, so a scenario reaches a guardrail's
	// service-unavailable path without a gateway configured to point elsewhere.
	Down = "GUARDIAN_DOWN"
)

Keywords that select an unsafe verdict.

View Source
const ChatPath = "/v1/chat/completions"

ChatPath is the OpenAI-compatible route both guardrails call.

View Source
const Port = 3016

Port is the container port used by the testbench.

View Source
const UnsafeCategory = "Violence"

UnsafeCategory is the NeMo Guard safety category an unsafe verdict names.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct{}

Service implements testbench.Service.

func New

func New() *Service

New returns a new guardian service.

func (*Service) Handler

func (s *Service) Handler() http.Handler

Handler returns the chat-completion endpoint.

func (*Service) Name

func (s *Service) Name() string

Name returns the service registration name.

func (*Service) Port

func (s *Service) Port() int

Port returns the service's listening port.

func (*Service) Stateful

func (s *Service) Stateful() bool

Stateful reports whether the service keeps request-specific state.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL