feat: 修复 AI 风险语义并隔离 Mock 数据

This commit is contained in:
weijuesen
2026-08-14 01:16:50 +08:00
parent 839ba91354
commit 74d1948d68
29 changed files with 650 additions and 113 deletions
+30 -2
View File
@@ -29,8 +29,36 @@ type AIDetection struct {
// AIDetectResponse /detect 响应
type AIDetectResponse struct {
Model string `json:"model"`
Detections []AIDetection `json:"detections"`
Model string `json:"model"`
ModelVersion string `json:"modelVersion"`
IsMock bool `json:"isMock"`
Status string `json:"status"`
AbnormalProbability float64 `json:"abnormalProbability"`
Detections []AIDetection `json:"detections"`
}
// AIDetectionStatus 从检测结果归纳 AI 状态;空检测或 unknown 不当作 healthy。
func AIDetectionStatus(detections []AIDetection) string {
if len(detections) == 0 {
return "unknown"
}
healthySeen := false
unknownSeen := false
for _, d := range detections {
class := strings.ToLower(strings.TrimSpace(d.ClassName))
switch class {
case "healthy":
healthySeen = true
case "", "unknown":
unknownSeen = true
default:
return "abnormal"
}
}
if healthySeen && !unknownSeen {
return "healthy"
}
return "unknown"
}
// AIClient ai-service HTTP 客户端