59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
|
|
package tencent
|
||
|
|
|
||
|
|
type Config struct {
|
||
|
|
Enabled bool
|
||
|
|
SecretID string
|
||
|
|
SecretKey string
|
||
|
|
Region string
|
||
|
|
BizType string
|
||
|
|
Timeout int
|
||
|
|
}
|
||
|
|
|
||
|
|
type ModerationSuggestion string
|
||
|
|
|
||
|
|
const (
|
||
|
|
SuggestionPass ModerationSuggestion = "Pass"
|
||
|
|
SuggestionReview ModerationSuggestion = "Review"
|
||
|
|
SuggestionBlock ModerationSuggestion = "Block"
|
||
|
|
)
|
||
|
|
|
||
|
|
type ModerationResponse struct {
|
||
|
|
Suggestion ModerationSuggestion
|
||
|
|
Label string
|
||
|
|
RiskLevel string
|
||
|
|
Keywords []string
|
||
|
|
RequestID string
|
||
|
|
}
|
||
|
|
|
||
|
|
type textModerationRequest struct {
|
||
|
|
Content string `json:"Content"`
|
||
|
|
BizType string `json:"BizType,omitempty"`
|
||
|
|
}
|
||
|
|
|
||
|
|
type tencentAPIResponse struct {
|
||
|
|
Response struct {
|
||
|
|
Suggestion string `json:"Suggestion"`
|
||
|
|
Label string `json:"Label"`
|
||
|
|
RiskLevel string `json:"RiskLevel"`
|
||
|
|
Keywords []struct {
|
||
|
|
Word string `json:"Word"`
|
||
|
|
} `json:"Keywords,omitempty"`
|
||
|
|
RequestID string `json:"RequestId"`
|
||
|
|
Error *struct {
|
||
|
|
Code string `json:"Code"`
|
||
|
|
Message string `json:"Message"`
|
||
|
|
} `json:"Error,omitempty"`
|
||
|
|
} `json:"Response"`
|
||
|
|
}
|
||
|
|
|
||
|
|
func ConfigFromAppConfig(cfg *Config) Config {
|
||
|
|
return Config{
|
||
|
|
Enabled: cfg.Enabled,
|
||
|
|
SecretID: cfg.SecretID,
|
||
|
|
SecretKey: cfg.SecretKey,
|
||
|
|
Region: cfg.Region,
|
||
|
|
BizType: cfg.BizType,
|
||
|
|
Timeout: cfg.Timeout,
|
||
|
|
}
|
||
|
|
}
|