Переглянути джерело

yinruoxi

feature:
    1.新增:添加触发大模型与语意检测开关。
dev_merge_mode
kira 1 рік тому
джерело
коміт
7a3fa9b3c1
1 змінених файлів з 39 додано та 25 видалено
  1. +39
    -25
      xueyi-modules/xueyi-nlt/src/main/java/com/xueyi/nlt/netty/server/handler/ChatServerHandler.java

+ 39
- 25
xueyi-modules/xueyi-nlt/src/main/java/com/xueyi/nlt/netty/server/handler/ChatServerHandler.java Переглянути файл

@@ -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");


Завантаження…
Відмінити
Зберегти