短句推送
This commit is contained in:
parent
c26c530122
commit
9a3e7691c8
@ -102,7 +102,11 @@ public class AliYunQianWen {
|
|||||||
if(lastGenerationResult != null){
|
if(lastGenerationResult != null){
|
||||||
qwenReplyResponse.setResut(lastGenerationResult.getOutput().getChoices().get(0).getMessage().getContent());
|
qwenReplyResponse.setResut(lastGenerationResult.getOutput().getChoices().get(0).getMessage().getContent());
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
onNext.accept("");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("千问最后调用结束时异常{}", e);
|
||||||
|
}
|
||||||
lastGenerationResult = null;
|
lastGenerationResult = null;
|
||||||
semaphore.release();
|
semaphore.release();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -138,11 +138,29 @@ public class BaseWebSocketProcess {
|
|||||||
}else{
|
}else{
|
||||||
tongYiCommunicationRest.setOnlyId(baseSession.getUserId().toString());
|
tongYiCommunicationRest.setOnlyId(baseSession.getUserId().toString());
|
||||||
}
|
}
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
qwenService.communication(tongYiCommunicationRest, message ->{
|
qwenService.communication(tongYiCommunicationRest, message ->{
|
||||||
//通知到客户端
|
//通知到客户端
|
||||||
|
|
||||||
if(tongYiCommunicationRest.getRequestId().equals(baseSession.getRequestId())){
|
if(tongYiCommunicationRest.getRequestId().equals(baseSession.getRequestId())){
|
||||||
message = message.replace("AI语言模型", "果宝儿Box");
|
String old = sb.toString() + message;
|
||||||
normalSendMsg(baseSession, message, AskTypeEnum.TTS.getCode());
|
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;
|
return;
|
||||||
}
|
}
|
||||||
log.info("已经有新的请求,不在推送到客户端SN:{} userId:{}", baseSession.getSn(), baseSession.getUserId());
|
log.info("已经有新的请求,不在推送到客户端SN:{} userId:{}", baseSession.getSn(), baseSession.getUserId());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user