moderation

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ModerationCategory

type ModerationCategory struct {
	Hate            bool `json:"hate"`
	HateThreatening bool `json:"hate_threatening"`
	Harassment      bool `json:"harassment"`
	SelfHarm        bool `json:"self_harm"`
	SelfHarmIntent  bool `json:"self_harm_intent"`
	Sexual          bool `json:"sexual"`
	SexualMinors    bool `json:"sexual_minors"`
	Violence        bool `json:"violence"`
	ViolenceGraphic bool `json:"violence_graphic"`
	Illicit         bool `json:"illicit"`
	IllicitViolent  bool `json:"illicit_violent"`
}

中度类别表示标出哪些类别 。

type ModerationProvider

type ModerationProvider interface {
	Name() string
	Moderate(ctx context.Context, req *ModerationRequest) (*ModerationResponse, error)
}

调和 Provider 为内容节制定义了接口.

type ModerationRequest

type ModerationRequest struct {
	Input  []string `json:"input"`            // Text inputs to moderate
	Images []string `json:"images,omitempty"` // Base64 images (optional)
	Model  string   `json:"model,omitempty"`  // Model to use
}

温和请求是温和请求。

type ModerationResponse

type ModerationResponse struct {
	Provider  string             `json:"provider"`
	Model     string             `json:"model"`
	Results   []ModerationResult `json:"results"`
	CreatedAt time.Time          `json:"created_at"`
}

温和反应是一种温和的反应。

type ModerationResult

type ModerationResult struct {
	Flagged    bool               `json:"flagged"`
	Categories ModerationCategory `json:"categories"`
	Scores     ModerationScores   `json:"scores"`
}

中度Result代表单一输入的结果.

type ModerationScores

type ModerationScores struct {
	Hate            float64 `json:"hate"`
	HateThreatening float64 `json:"hate_threatening"`
	Harassment      float64 `json:"harassment"`
	SelfHarm        float64 `json:"self_harm"`
	SelfHarmIntent  float64 `json:"self_harm_intent"`
	Sexual          float64 `json:"sexual"`
	SexualMinors    float64 `json:"sexual_minors"`
	Violence        float64 `json:"violence"`
	ViolenceGraphic float64 `json:"violence_graphic"`
	Illicit         float64 `json:"illicit"`
	IllicitViolent  float64 `json:"illicit_violent"`
}

中调分数包含每个类别的信心分数.

type OpenAIConfig

type OpenAIConfig struct {
	providers.BaseProviderConfig `yaml:",inline"`
}

OpenAIConfig 配置 OpenAI 内容审核提供者. 嵌入 providers.BaseProviderConfig 以复用 APIKey、BaseURL、Model、Timeout 字段。

func DefaultOpenAIConfig

func DefaultOpenAIConfig() OpenAIConfig

DefaultOpenAIConfig 返回默认 OpenAI 内容审核配置.

type OpenAIProvider

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

OpenAIProvider使用OpenAI API执行节制.

func NewOpenAIProvider

func NewOpenAIProvider(cfg OpenAIConfig) *OpenAIProvider

NewOpenAIProvider创建了一个新的OpenAI温和提供商.

func (*OpenAIProvider) Moderate

适度检查政策违规内容.

func (*OpenAIProvider) Name

func (p *OpenAIProvider) Name() string

Jump to

Keyboard shortcuts

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