moderation

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package moderation 提供内容审核模型接口与数据结构。

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 {
	APIKey  string        `json:"api_key" yaml:"api_key"`
	BaseURL string        `json:"base_url" yaml:"base_url"`
	Model   string        `json:"model,omitempty" yaml:"model,omitempty"`
	Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
}

OpenAIConfig 配置 OpenAI 节奏提供者 。

func DefaultOpenAIConfig

func DefaultOpenAIConfig() OpenAIConfig

默认 OpenAIConfig 返回默认 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