| @@ -102,6 +102,8 @@ public class ChatServerHandler extends SimpleChannelInboundHandler<TextWebSocket | |||
| } | |||
| // 获取到发送人的设备号 | |||
| String devId = jsonObject.getString("devId"); | |||
| Boolean llm = jsonObject.containsKey("llm")?jsonObject.getBoolean("llm"): true; | |||
| Boolean integrityDetection = jsonObject.containsKey("integrityDetection")?jsonObject.getBoolean("integrityDetection"): true; | |||
| Long operatorId = jsonObject.getLong("operatorId"); | |||
| // 获取到发送人的用户id | |||
| String msg = jsonObject.getString("msg"); | |||
| @@ -153,31 +155,33 @@ public class ChatServerHandler extends SimpleChannelInboundHandler<TextWebSocket | |||
| INSTANCE.reply(channel,msg, jo,enterpriseName,"知识库"); | |||
| return; | |||
| } | |||
| else { | |||
| // 语意判断 | |||
| WordProcessVo wordProcessVo = new WordProcessVo(); | |||
| wordProcessVo.setMetadata(msg); | |||
| WordProcessVo result = INSTANCE.wordProcessService.semanticIntegrityDetection(wordProcessVo); | |||
| if (result != null) { | |||
| System.out.println(result.getProcessedResult()); | |||
| // 判断结果 | |||
| switch (result.getProcessedResult()){ | |||
| case "0": | |||
| // 返回前端,抛弃 | |||
| JSONObject jo = new JSONObject(); | |||
| jo.put("action","chat"); | |||
| jo.put("motion","idle"); | |||
| jo.put("traceId",""); | |||
| jo.put("status",2); | |||
| jo.put("code", -1); | |||
| jo.put("tts",""); | |||
| reply(channel, msg,jo, enterpriseName,"大模型"); | |||
| return; | |||
| case "1": | |||
| case "2": | |||
| break; | |||
| default: | |||
| if (llm == true) { | |||
| if (integrityDetection == true) { | |||
| // 语意判断 | |||
| WordProcessVo wordProcessVo = new WordProcessVo(); | |||
| wordProcessVo.setMetadata(msg); | |||
| WordProcessVo result = INSTANCE.wordProcessService.semanticIntegrityDetection(wordProcessVo); | |||
| if (result != null) { | |||
| System.out.println(result.getProcessedResult()); | |||
| // 判断结果 | |||
| switch (result.getProcessedResult()){ | |||
| case "0": | |||
| // 返回前端,抛弃 | |||
| JSONObject jo = new JSONObject(); | |||
| jo.put("action","chat"); | |||
| jo.put("motion","idle"); | |||
| jo.put("traceId",""); | |||
| jo.put("status",2); | |||
| jo.put("code", -1); | |||
| jo.put("tts",""); | |||
| reply(channel, msg,jo, enterpriseName,"大模型"); | |||
| return; | |||
| case "1": | |||
| case "2": | |||
| break; | |||
| default: | |||
| } | |||
| } | |||
| } | |||
| JSONObject jo = new JSONObject(); | |||
| @@ -189,7 +193,17 @@ public class ChatServerHandler extends SimpleChannelInboundHandler<TextWebSocket | |||
| channel.writeAndFlush(new TextWebSocketFrame(jo.toJSONString())); | |||
| INSTANCE.logService.record(jo,msg,enterpriseName,"大模型"); | |||
| sendMsg(devId, msg); | |||
| return; | |||
| } | |||
| //未触发大模型的结束case | |||
| JSONObject jo = new JSONObject(); | |||
| jo.put("action","chat"); | |||
| jo.put("motion","idle"); | |||
| jo.put("traceId",""); | |||
| jo.put("status",2); | |||
| jo.put("code", -1); | |||
| jo.put("tts",""); | |||
| reply(channel, msg,jo, enterpriseName,"大模型"); | |||
| } catch (Exception e) { | |||
| JSONObject jo = new JSONObject(); | |||
| jo.put("action","chat"); | |||