短句推送

This commit is contained in:
wulin 2023-10-13 17:36:36 +08:00
parent c26c530122
commit 9a3e7691c8
2 changed files with 25 additions and 3 deletions

View File

@ -102,7 +102,11 @@ public class AliYunQianWen {
if(lastGenerationResult != null){
qwenReplyResponse.setResut(lastGenerationResult.getOutput().getChoices().get(0).getMessage().getContent());
}
try {
onNext.accept("");
} catch (Exception e) {
log.info("千问最后调用结束时异常{}", e);
}
lastGenerationResult = null;
semaphore.release();
}

View File

@ -138,11 +138,29 @@ public class BaseWebSocketProcess {
}else{
tongYiCommunicationRest.setOnlyId(baseSession.getUserId().toString());
}
StringBuilder sb = new StringBuilder();
qwenService.communication(tongYiCommunicationRest, message ->{
//通知到客户端
if(tongYiCommunicationRest.getRequestId().equals(baseSession.getRequestId())){
message = message.replace("AI语言模型", "果宝儿Box");
normalSendMsg(baseSession, message, AskTypeEnum.TTS.getCode());
String old = sb.toString() + message;
int d = old.indexOf("");
int j = old.indexOf("");
int a = old.indexOf("");
int b = old.indexOf("\n");
int c = old.indexOf("");
int n = old.indexOf("\\n");
int m = Math.max(Math.max(Math.max(Math.max(d, j), Math.max(a, b)), c), n);
if(m > 0){
sb.setLength(0);
sb.append(old.substring(m));
old = old.substring(0, m);
//清空
normalSendMsg(baseSession, old, AskTypeEnum.TTS.getCode());
}else{
sb.append(message);
}
return;
}
log.info("已经有新的请求不在推送到客户端SN{} userId:{}", baseSession.getSn(), baseSession.getUserId());