guard

package
v0.0.0-...-dfb39b5 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuiltinGuard

type BuiltinGuard struct {
	// contains filtered or unexported fields
}

BuiltinGuard is a thin adapter over the inputguard package that implements GuardService. Swap out the underlying Check call to plug in a different implementation.

func NewBuiltinGuard

func NewBuiltinGuard() *BuiltinGuard

func (*BuiltinGuard) CheckInput

type GuardResult

type GuardResult struct {
	Safe       bool               `json:"safe"`
	Categories map[string]float64 `json:"categories,omitempty"`
	Blocked    bool               `json:"blocked"`
	Reason     string             `json:"reason,omitempty"`
}

GuardResult contains the classification outcome from a guard check.

type GuardService

type GuardService interface {
	CheckInput(ctx context.Context, input string, history []types.AiConversationMessage) (*GuardResult, error)
}

GuardService evaluates user inputs for prompt injection attempts. Both the built-in guard and external providers implement this interface.

type LlamaGuard

type LlamaGuard struct {
	// contains filtered or unexported fields
}

LlamaGuard is a guard adapter that uses Meta's Llama Guard 3 model via an Ollama-compatible OpenAI API endpoint.

func NewLlamaGuard

func NewLlamaGuard(provider *types.LlmProvider, apiKey string) *LlamaGuard

NewLlamaGuard creates a Llama Guard adapter from an LlmProvider's config.

func (*LlamaGuard) CheckInput

func (lg *LlamaGuard) CheckInput(ctx context.Context, input string, history []types.AiConversationMessage) (*GuardResult, error)

CheckInput sends the user input to Llama Guard for classification.

Jump to

Keyboard shortcuts

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