优化询问太快和太多并发的文案提示
This commit is contained in:
parent
b37c185dc3
commit
106ddb6e50
@ -204,6 +204,11 @@ public abstract class ActionCommand {
|
|||||||
//保存记录
|
//保存记录
|
||||||
return actionSendMessage.sendMsgTongYiFinished(action, baseSession, data.getResut());
|
return actionSendMessage.sendMsgTongYiFinished(action, baseSession, data.getResut());
|
||||||
}else{
|
}else{
|
||||||
|
if(data.getCode() == 422){
|
||||||
|
return sendMessage(action, baseSession, "询问太快了,请慢一点。容我思考思考!", AskTypeEnum.NONE.getCode(), actionSendMessage);
|
||||||
|
}else if(data.getCode() == 429){
|
||||||
|
return sendMessage(action, baseSession, "询问问题用户过多,请稍等在问!", AskTypeEnum.NONE.getCode(), actionSendMessage);
|
||||||
|
}
|
||||||
return sendMessage(action, baseSession, "很抱歉,我无法回答您的问题,请换一个问题。", AskTypeEnum.NONE.getCode(), actionSendMessage);
|
return sendMessage(action, baseSession, "很抱歉,我无法回答您的问题,请换一个问题。", AskTypeEnum.NONE.getCode(), actionSendMessage);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,11 +1,6 @@
|
|||||||
package com.qiuguo.iot.third.nlp;
|
package com.qiuguo.iot.third.nlp;
|
||||||
|
|
||||||
import com.alibaba.dashscope.aigc.generation.Generation;
|
import com.alibaba.xingchen.ApiException;
|
||||||
import com.alibaba.dashscope.aigc.generation.GenerationResult;
|
|
||||||
import com.alibaba.dashscope.aigc.generation.models.QwenParam;
|
|
||||||
import com.alibaba.dashscope.common.MessageManager;
|
|
||||||
import com.alibaba.dashscope.common.ResultCallback;
|
|
||||||
import com.alibaba.dashscope.common.Role;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
@ -41,6 +36,7 @@ public class AliYunXingChen {
|
|||||||
ChatApiSub api;
|
ChatApiSub api;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<Message> messages = new ArrayList<>(50);
|
List<Message> messages = new ArrayList<>(50);
|
||||||
|
|
||||||
|
|
||||||
@ -86,6 +82,7 @@ public class AliYunXingChen {
|
|||||||
QWenReplyResponse qwenReplyResponse) {
|
QWenReplyResponse qwenReplyResponse) {
|
||||||
log.info("调用通义星尘内存缓存回答:{}", msg);
|
log.info("调用通义星尘内存缓存回答:{}", msg);
|
||||||
Message message = Message.builder().name(userName).role("user").content(msg).build();
|
Message message = Message.builder().name(userName).role("user").content(msg).build();
|
||||||
|
|
||||||
addMessage(message);
|
addMessage(message);
|
||||||
return sendMsg(onNext, qwenReplyResponse);
|
return sendMsg(onNext, qwenReplyResponse);
|
||||||
}
|
}
|
||||||
@ -112,12 +109,17 @@ public class AliYunXingChen {
|
|||||||
addMessage(message1);
|
addMessage(message1);
|
||||||
onNext.finish();
|
onNext.finish();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return Mono.just(true);
|
return Mono.just(true);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.info("调用星尘异常{}", e);
|
log.info("调用星尘异常{}", e);
|
||||||
qwenReplyResponse.setCode(500);
|
ApiException apiException = (ApiException)e.getCause().getCause();
|
||||||
|
|
||||||
|
qwenReplyResponse.setCode(apiException.getCode());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return Mono.just(false);
|
return Mono.just(false);
|
||||||
}
|
}
|
||||||
@ -142,6 +144,7 @@ public class AliYunXingChen {
|
|||||||
Message m = JSONObject.toJavaObject(jsonArray.getJSONObject(i), Message.class);
|
Message m = JSONObject.toJavaObject(jsonArray.getJSONObject(i), Message.class);
|
||||||
messages.add(m);
|
messages.add(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.info("聊天缓存转换异常{}", e);
|
log.info("聊天缓存转换异常{}", e);
|
||||||
|
|||||||
@ -50,7 +50,7 @@ qiuguo:
|
|||||||
tts:
|
tts:
|
||||||
#max:
|
#max:
|
||||||
# text: 30 #当发送给前端文字超过改值时,分批发送给前端
|
# text: 30 #当发送给前端文字超过改值时,分批发送给前端
|
||||||
suanfa: true #nacos控制变化
|
suanfa: false #nacos控制变化
|
||||||
url: http://192.168.8.211:18000/run/predict # #http://47.110.40.30:18000/run/predict # #算法语音合成
|
url: http://192.168.8.211:18000/run/predict # #http://47.110.40.30:18000/run/predict # #算法语音合成
|
||||||
lac:
|
lac:
|
||||||
#type: suanfa #nacos控制变化
|
#type: suanfa #nacos控制变化
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user