openaimoderation

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const PluginName = "openai_moderation"

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionSettings

type ActionSettings struct {
	Message string `mapstructure:"message"`
}

type ModerationData

type ModerationData struct {
	Model             string             `json:"model,omitempty"`
	CategoryScores    map[string]float64 `json:"category_scores,omitempty"`
	MaxScore          float64            `json:"max_score"`
	MaxScoreCategory  string             `json:"max_score_category,omitempty"`
	FlaggedByOpenAI   bool               `json:"flagged_by_openai"`
	FlaggedCategories []violation        `json:"flagged_categories,omitempty"`
	Decision          string             `json:"decision,omitempty"`
}

type Plugin

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

func New

func New(registry *adapter.Registry, baseURL string, timeout time.Duration, logger *slog.Logger) *Plugin

func (*Plugin) Execute

func (p *Plugin) Execute(ctx context.Context, in appplugins.ExecInput) (*appplugins.Result, error)

func (*Plugin) MandatoryStages

func (p *Plugin) MandatoryStages() []policy.Stage

func (*Plugin) MutatesMetadata

func (p *Plugin) MutatesMetadata() bool

func (*Plugin) MutatesRequestBody

func (p *Plugin) MutatesRequestBody() bool

func (*Plugin) MutatesResponseBody

func (p *Plugin) MutatesResponseBody() bool

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) SupportedModes

func (p *Plugin) SupportedModes() []policy.Mode

func (*Plugin) SupportedStages

func (p *Plugin) SupportedStages() []policy.Stage

func (*Plugin) ValidateConfig

func (p *Plugin) ValidateConfig(settings map[string]any) error

type Settings

type Settings struct {
	APIKey         string             `mapstructure:"api_key"` // #nosec G101 -- config field name, not a credential
	Model          string             `mapstructure:"model"`
	Stages         []string           `mapstructure:"stages"`
	Categories     []string           `mapstructure:"categories"`
	Thresholds     map[string]float64 `mapstructure:"thresholds"`
	BlockOnFlagged bool               `mapstructure:"block_on_flagged"`
	Action         ActionSettings     `mapstructure:"action"`
}

Jump to

Keyboard shortcuts

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