moderation

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder interface {
	AddImage(url string) Builder
	AddText(text string) Builder
	Clear() Builder
	Execute() ([]*Result, error)
	SetMinConfidence(minPercent int) Builder
}

Builder is a builder for the Moderation API.

type Result

type Result struct {
	Flagged                   bool                `json:"flagged"`
	Categories                map[string]bool     `json:"categories"`
	CategoryScores            map[string]float64  `json:"category_scores"`
	CategoryAppliedInputTypes map[string][]string `json:"category_applied_input_types"`

	// filled by us for convenience
	Input string `json:"-"`
}

Result is a single result of the Moderation API, includes the input, whether it was flagged and moderation categories with their scores.

func (*Result) WithConfidence

func (r *Result) WithConfidence(minPercent int)

WithConfidence checks if the result passes the confidence threshold. If not, it sets the result as not flagged. Categories with low confidence are removed from the result.

type Service

type Service interface {
	NewModerationBuilder() Builder
}

Service defines methods to operate on moderation API.

Jump to

Keyboard shortcuts

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