mirror of
https://github.com/alibaba/higress.git
synced 2026-06-06 03:07:28 +08:00
feat(ai-security-guard): add Embedding API content detection support (#3895)
Signed-off-by: root <jianwei.wjw@alibaba-inc.com>
This commit is contained in:
@@ -118,6 +118,7 @@ const (
|
||||
ApiTextGeneration = "text_generation"
|
||||
ApiImageGeneration = "image_generation"
|
||||
ApiMCP = "mcp"
|
||||
ApiEmbedding = "embedding"
|
||||
)
|
||||
|
||||
// provider types
|
||||
@@ -206,6 +207,7 @@ type AISecurityConfig struct {
|
||||
ResponseStreamContentJsonPath string
|
||||
ResponseContentFallbackJsonPaths []string
|
||||
ResponseStreamContentFallbackJsonPaths []string
|
||||
ResponseErrorContentJsonPath string
|
||||
DenyCode int64
|
||||
DenyMessage string
|
||||
ProtocolOriginal bool
|
||||
@@ -223,7 +225,7 @@ type AISecurityConfig struct {
|
||||
ConsumerRequestCheckService []map[string]interface{}
|
||||
ConsumerResponseCheckService []map[string]interface{}
|
||||
ConsumerRiskLevel []map[string]interface{}
|
||||
// text_generation, image_generation, etc.
|
||||
// text_generation, image_generation, embedding, etc.
|
||||
ApiType string
|
||||
// openai, qwen, comfyui, etc.
|
||||
ProviderType string
|
||||
@@ -355,6 +357,9 @@ func (config *AISecurityConfig) Parse(json gjson.Result) error {
|
||||
} else if exists {
|
||||
config.ResponseStreamContentFallbackJsonPaths = paths
|
||||
}
|
||||
if obj := json.Get("responseErrorContentJsonPath"); obj.Exists() {
|
||||
config.ResponseErrorContentJsonPath = obj.String()
|
||||
}
|
||||
if obj := json.Get("contentModerationLevelBar"); obj.Exists() {
|
||||
config.ContentModerationLevelBar = obj.String()
|
||||
if LevelToInt(config.ContentModerationLevelBar) <= 0 {
|
||||
|
||||
Reference in New Issue
Block a user