|
|
@ -21,10 +21,6 @@ import org.springframework.stereotype.Component; |
|
|
* 3. 视频审核(异步) |
|
|
* 3. 视频审核(异步) |
|
|
* 4. 取消视频审核任务(直播流) |
|
|
* 4. 取消视频审核任务(直播流) |
|
|
* |
|
|
* |
|
|
* 特性: |
|
|
|
|
|
* - 自动切换备用节点(cn-beijing) |
|
|
|
|
|
* - 从 application.yml 中读取配置 |
|
|
|
|
|
* - 返回 null 表示请求失败(业务层自行判断) |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
@Component |
|
|
@Component |
|
|
@ -105,7 +101,7 @@ public class AliyunContentAuditUtil { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// ===================== 文本审核 =====================
|
|
|
// ===================== 普通文本审核 =====================
|
|
|
public TextModerationResponse textModeration(String content) { |
|
|
public TextModerationResponse textModeration(String content) { |
|
|
return executeWithFailover(client -> { |
|
|
return executeWithFailover(client -> { |
|
|
JSONObject params = new JSONObject(); |
|
|
JSONObject params = new JSONObject(); |
|
|
@ -120,7 +116,7 @@ public class AliyunContentAuditUtil { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 批量文本审核(上限100条,单条不超过600字) |
|
|
* 批量普通文本审核(上限100条,单条不超过600字) |
|
|
*/ |
|
|
*/ |
|
|
public TextModerationResponse batchTextModeration(List<String> contents) { |
|
|
public TextModerationResponse batchTextModeration(List<String> contents) { |
|
|
if (contents == null || contents.isEmpty()) { |
|
|
if (contents == null || contents.isEmpty()) { |
|
|
@ -150,8 +146,8 @@ public class AliyunContentAuditUtil { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// ===================== 文本审核Plus =====================
|
|
|
// ===================== 文本审核Plus =====================
|
|
|
//nickname_detection_pro 用户昵称检测_专业版(用户昵称) ;ugc_moderation_byllm_pro UGC场景文本审核大模型服务_专业版(个人简介 / 作品内容) ;
|
|
|
//nickname_detection_pro 用户昵称检测_专业版; ugc_moderation_byllm_pro UGC 场景文本审核大模型服务_专业版;
|
|
|
//comment_detection_pro 公聊评论内容检测_专业版(评论); ugc_moderation_byllm UGC场景文本审核大模型服务 (作品标题)
|
|
|
//comment_detection_pro 公聊评论内容检测_专业版(评论); ugc_moderation_byllm UGC 场景文本审核大模型服务;
|
|
|
public TextModerationPlusResponse textModerationPlus(String content, String service) { |
|
|
public TextModerationPlusResponse textModerationPlus(String content, String service) { |
|
|
return executeWithFailover(client -> { |
|
|
return executeWithFailover(client -> { |
|
|
JSONObject params = new JSONObject(); |
|
|
JSONObject params = new JSONObject(); |
|
|
@ -196,9 +192,8 @@ public class AliyunContentAuditUtil { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// ===================== 图片审核 =====================
|
|
|
// ===================== 图片审核 =====================
|
|
|
// 头像图片检测:profilePhotoCheck (头像) ; AI生成图片鉴别_含隐式标识版:aigcDetectorFull(AI生成图片) ;
|
|
|
// 头像图片检测:profilePhotoCheck; AI生成图片鉴别_含隐式标识版:aigcDetectorFull;大小模型融合图片审核服务:postlmageCheckByVL;
|
|
|
// 大小模型融合图片审核服务:postlmageCheckByVL (用户上传的图片) ; OSS基线检测(OSS普惠版专用):oss_baselineCheck
|
|
|
// 通用图片审核大模型服务:baselineCheckByVL; 图片万物识别:generalRecognition; 营销素材检测:advertisingCheck
|
|
|
// 通用图片审核大模型服务:baselineCheckByVL(用户作品);图片万物识别:generalRecognition ;营销素材检测:advertisingCheck
|
|
|
|
|
|
public ImageModerationResponse imageModeration(String imageUrl, String service) { |
|
|
public ImageModerationResponse imageModeration(String imageUrl, String service) { |
|
|
return executeWithFailover(client -> { |
|
|
return executeWithFailover(client -> { |
|
|
JSONObject params = new JSONObject(); |
|
|
JSONObject params = new JSONObject(); |
|
|
@ -217,7 +212,7 @@ public class AliyunContentAuditUtil { |
|
|
return executeWithFailover(client -> { |
|
|
return executeWithFailover(client -> { |
|
|
JSONObject params = new JSONObject(); |
|
|
JSONObject params = new JSONObject(); |
|
|
params.put("imageUrl", imageUrl); |
|
|
params.put("imageUrl", imageUrl); |
|
|
params.put("dataId", java.util.UUID.randomUUID().toString()); |
|
|
// params.put("dataId", java.util.UUID.randomUUID().toString());
|
|
|
|
|
|
|
|
|
ImageAsyncModerationRequest request = new ImageAsyncModerationRequest() |
|
|
ImageAsyncModerationRequest request = new ImageAsyncModerationRequest() |
|
|
.setService(service != null ? service : "baselineCheckByVL") |
|
|
.setService(service != null ? service : "baselineCheckByVL") |
|
|
@ -227,6 +222,7 @@ public class AliyunContentAuditUtil { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ===================== 查询图片审核异步结果 =====================
|
|
|
public DescribeImageModerationResultResponse describeImageModerationResult(String reqId) { |
|
|
public DescribeImageModerationResultResponse describeImageModerationResult(String reqId) { |
|
|
return executeWithFailover(client -> { |
|
|
return executeWithFailover(client -> { |
|
|
DescribeImageModerationResultRequest request = new DescribeImageModerationResultRequest() |
|
|
DescribeImageModerationResultRequest request = new DescribeImageModerationResultRequest() |
|
|
@ -250,16 +246,14 @@ public class AliyunContentAuditUtil { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 视频审核不支持批量,使用 videoModeration 逐个调用
|
|
|
|
|
|
|
|
|
|
|
|
// ===================== 查询视频审核结果 =====================
|
|
|
// ===================== 查询视频审核结果 =====================
|
|
|
public VideoModerationResultResponse videoModerationResult(String taskId) { |
|
|
public VideoModerationResultResponse videoModerationResult(String taskId, String service) { |
|
|
return executeWithFailover(client -> { |
|
|
return executeWithFailover(client -> { |
|
|
JSONObject params = new JSONObject(); |
|
|
JSONObject params = new JSONObject(); |
|
|
params.put("taskId", taskId); |
|
|
params.put("taskId", taskId); |
|
|
|
|
|
|
|
|
VideoModerationResultRequest request = new VideoModerationResultRequest() |
|
|
VideoModerationResultRequest request = new VideoModerationResultRequest() |
|
|
.setService("videoDetection") |
|
|
.setService(service != null ? service : "videoDetection") |
|
|
.setServiceParameters(params.toJSONString()); |
|
|
.setServiceParameters(params.toJSONString()); |
|
|
|
|
|
|
|
|
return client.videoModerationResult(request); |
|
|
return client.videoModerationResult(request); |
|
|
|