feat: 修复 AI 风险语义并隔离 Mock 数据
This commit is contained in:
@@ -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 客户端
|
||||
|
||||
Reference in New Issue
Block a user