Documentation
¶
Overview ¶
Package guardrail provides output validation guardrails for AI agent responses.
Guardrails enforce contracts on agent output — reject, retry, or constrain responses based on structural, lexical, or semantic rules.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BannedWordsGuardrail ¶
type BannedWordsGuardrail struct {
// contains filtered or unexported fields
}
BannedWordsGuardrail validates that output does not contain any banned words.
func NewBannedWordsGuardrail ¶
func NewBannedWordsGuardrail(words ...string) *BannedWordsGuardrail
NewBannedWordsGuardrail creates a BannedWordsGuardrail with the given banned words.
func (*BannedWordsGuardrail) Validate ¶
func (g *BannedWordsGuardrail) Validate(output string) error
Validate checks the output for banned words.
type ContainsGuardrail ¶
type ContainsGuardrail struct {
// contains filtered or unexported fields
}
ContainsGuardrail validates that output contains all required substrings.
func NewContainsGuardrail ¶
func NewContainsGuardrail(substrings ...string) *ContainsGuardrail
NewContainsGuardrail creates a ContainsGuardrail requiring the given substrings.
func (*ContainsGuardrail) Validate ¶
func (g *ContainsGuardrail) Validate(output string) error
Validate checks the output contains all required substrings.
type JSONSchemaGuardrail ¶
type JSONSchemaGuardrail struct {
// contains filtered or unexported fields
}
JSONSchemaGuardrail validates that output is valid JSON matching a JSON Schema (draft-07).
func NewJSONSchemaGuardrail ¶
func NewJSONSchemaGuardrail(schemaStr string) (*JSONSchemaGuardrail, error)
NewJSONSchemaGuardrail creates a JSONSchemaGuardrail with the given JSON Schema string. Returns error if the schema is invalid.
func (*JSONSchemaGuardrail) Validate ¶
func (g *JSONSchemaGuardrail) Validate(output string) error
Validate checks the output conforms to the JSON schema.
type LengthGuardrail ¶
type LengthGuardrail struct {
// contains filtered or unexported fields
}
LengthGuardrail validates that output length is within the specified bounds.
func NewLengthGuardrail ¶
func NewLengthGuardrail(min, max int) *LengthGuardrail
NewLengthGuardrail creates a LengthGuardrail with the given min/max bounds.
func (*LengthGuardrail) Validate ¶
func (g *LengthGuardrail) Validate(output string) error
Validate checks the output length is within bounds.
type RegexGuardrail ¶
type RegexGuardrail struct {
// contains filtered or unexported fields
}
RegexGuardrail validates that output matches a given regular expression.
func NewRegexGuardrail ¶
func NewRegexGuardrail(pattern string) (*RegexGuardrail, error)
NewRegexGuardrail creates a RegexGuardrail. Returns error if pattern is invalid.
func (*RegexGuardrail) Validate ¶
func (g *RegexGuardrail) Validate(output string) error
Validate checks the output against the regex pattern.