| @@ -12,7 +12,9 @@ import org.springframework.web.bind.annotation.RequestParam; | |||||
| public interface RemoteBaiduNLPService { | public interface RemoteBaiduNLPService { | ||||
| @PostMapping(path = "/oauth/2.0/token", consumes = "application/x-www-form-urlencoded") | @PostMapping(path = "/oauth/2.0/token", consumes = "application/x-www-form-urlencoded") | ||||
| JSONObject getAccessToken(@RequestBody String body); | |||||
| JSONObject getAccessToken(@RequestParam("client_id") String client_id, | |||||
| @RequestParam("client_secret") String client_secret, | |||||
| @RequestParam("grant_type") String grant_type); | |||||
| @PostMapping(path = "/rpc/2.0/nlp/v2/dnnlm_cn", consumes = "application/json") | @PostMapping(path = "/rpc/2.0/nlp/v2/dnnlm_cn", consumes = "application/json") | ||||
| JSONObject detected(@RequestParam(value = "charset", defaultValue = "UTF-8") String charset, | JSONObject detected(@RequestParam(value = "charset", defaultValue = "UTF-8") String charset, | ||||
| @@ -382,7 +382,7 @@ public class DmIntentController extends BaseController<DmIntentQuery, DmIntentDt | |||||
| if (enterpriseDtoR.isOk()) { | if (enterpriseDtoR.isOk()) { | ||||
| enterpriseName = enterpriseDtoR.getData().getName(); | enterpriseName = enterpriseDtoR.getData().getName(); | ||||
| } | } | ||||
| recordVo.setTenantId(Long.valueOf(manDeviceDtoR.getData().getTId())); | |||||
| recordVo.setTenantId(manDeviceDtoR.getData().getTId()); | |||||
| DmIntentResponse response = new DmIntentResponse(); | DmIntentResponse response = new DmIntentResponse(); | ||||
| //先调用意图 | //先调用意图 | ||||
| //根据技能调用知识库或大模型 | //根据技能调用知识库或大模型 | ||||
| @@ -183,7 +183,7 @@ public class DmIntentServiceImpl extends BaseServiceImpl<DmIntentQuery, DmIntent | |||||
| R<DmManDeviceDto> manDeviceDtoR = manDeviceService.manDeviceInfoInner(intent.getDevId()); | R<DmManDeviceDto> manDeviceDtoR = manDeviceService.manDeviceInfoInner(intent.getDevId()); | ||||
| Long enterpriseId = manDeviceDtoR.getData().getTId(); | Long enterpriseId = manDeviceDtoR.getData().getTId(); | ||||
| String enterpriseName = ""; | String enterpriseName = ""; | ||||
| R<SysEnterpriseDto> enterpriseDtoR = remoteEnterpriseService.getInfo(Long.valueOf(enterpriseId)); | |||||
| R<SysEnterpriseDto> enterpriseDtoR = remoteEnterpriseService.getInfo(enterpriseId); | |||||
| if (enterpriseDtoR.isOk()) { | if (enterpriseDtoR.isOk()) { | ||||
| enterpriseName = enterpriseDtoR.getData().getName(); | enterpriseName = enterpriseDtoR.getData().getName(); | ||||
| } | } | ||||
| @@ -23,28 +23,25 @@ public class DmWordProcessServiceImpl implements IDmWordProcessService { | |||||
| public WordProcessVo semanticIntegrityDetection (WordProcessVo wordProcessVo){ | public WordProcessVo semanticIntegrityDetection (WordProcessVo wordProcessVo){ | ||||
| log.info("元数据:" + wordProcessVo.getMetadata()); | log.info("元数据:" + wordProcessVo.getMetadata()); | ||||
| String body = "grant_type=client_credentials&client_id=" + baiduConfig.getApiKey() + "&client_secret=" + baiduConfig.getSecretKey(); | |||||
| JSONObject accessJson = remoteBaiduNLPService.getAccessToken(body); | |||||
| JSONObject accessJson = remoteBaiduNLPService.getAccessToken(baiduConfig.getApiKey(), baiduConfig.getSecretKey(), "client_credentials"); | |||||
| JSONObject result = remoteBaiduNLPService.detected("UTF-8", accessJson.getString("access_token"), "{\"text\":\"" + wordProcessVo.getMetadata() + "\"}"); | JSONObject result = remoteBaiduNLPService.detected("UTF-8", accessJson.getString("access_token"), "{\"text\":\"" + wordProcessVo.getMetadata() + "\"}"); | ||||
| if(result.containsKey("ppl")){ | |||||
| if(result != null){ | |||||
| if(result.containsKey("error_code")){ | |||||
| String errorMsg = String.format("语义完整性检测失败,错误码:%d,错误信息:%s", result.getInteger("error_code"),result.getString("error_msg")); | |||||
| log.error(errorMsg); | |||||
| if(result != null){ | |||||
| if(result.containsKey("error_code")){ | |||||
| String errorMsg = String.format("语义完整性检测失败,错误码:%d,错误信息:%s", result.getInteger("error_code"),result.getString("error_msg")); | |||||
| log.error(errorMsg); | |||||
| }else{ | |||||
| Double ppl = result.getDouble("ppl"); | |||||
| if(ppl < 300) { | |||||
| wordProcessVo.setProcessedResult("2"); | |||||
| }else if(ppl > 1000){ | |||||
| wordProcessVo.setProcessedResult("0"); | |||||
| }else{ | }else{ | ||||
| Double ppl = result.getDouble("ppl"); | |||||
| if(ppl < 300) { | |||||
| wordProcessVo.setProcessedResult("2"); | |||||
| }else if(ppl > 1000){ | |||||
| wordProcessVo.setProcessedResult("0"); | |||||
| }else{ | |||||
| wordProcessVo.setProcessedResult("1"); | |||||
| } | |||||
| log.info("语义完整性检测结果:" + wordProcessVo.getProcessedResult()); | |||||
| wordProcessVo.setProcessedResult("1"); | |||||
| } | } | ||||
| }else{ | |||||
| log.error("语义完整性检测失败,未获取到返回结果"); | |||||
| log.info("语义完整性检测结果:" + wordProcessVo.getProcessedResult()); | |||||
| } | } | ||||
| }else{ | |||||
| log.error("语义完整性检测失败,未获取到返回结果"); | |||||
| } | } | ||||
| return wordProcessVo; | return wordProcessVo; | ||||
| } | } | ||||