我在服务端调用内容安全校验msgSecCheck接口,测试时候,输入张三大傻逼,无法正常检验敏感词,显示通过,输入张三傻逼,张三搭傻逼,都可以正常校验,接口version用的2,场景用的修改资料1,一开始以为是编码问题,header里设置了utf-8依然这样,请问怎么解决。
代码片段:
JSONObject json = new JSONObject();
json.put("content", content);
json.put("version", 2);
json.put("scene", scene);
json.put("openid", openid);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(requestUrl))
.header("Content-Type", "application/json;charset=utf-8")
.POST(HttpRequest.BodyPublishers.ofString(json.toString()))
.build();
JSONObject result = new JSONObject();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
result = JSONObject.parseObject(response.body()).getJSONObject("result");
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
你好,烦请提供具体的traceid,以便进行后续核实。
"errcode": 0,
"errmsg": "ok",
"detail": [
{
"strategy": "keyword",
"errcode": 0
},
{
"strategy": "content_model",
"errcode": 0,
"suggest": "pass",
"label": 100,
"prob": 90
}
],
"trace_id": "68253e0e-5e787654-2a35b987",
"result": {
"suggest": "pass",
"label": 100
}
}
张三大傻逼pass,小明大傻逼risky😒
先用postman测接口,排除代码编码问题。如果还不行,就换场景,还不行就是这个检测模型不行,要想拦截就自己加自定义关键词