Commit 1885b978 by zhangxingmin

push

parent 95a346f4
...@@ -46,28 +46,33 @@ public class ApiAiStreamServiceImpl implements ApiAiStreamService { ...@@ -46,28 +46,33 @@ public class ApiAiStreamServiceImpl implements ApiAiStreamService {
} catch (BusinessException e) { } catch (BusinessException e) {
int code = e.getCode(); int code = e.getCode();
if (code == ResultCode.SENSITIVE_WORDS_EXIST.getCode()) { if (code == ResultCode.SENSITIVE_WORDS_EXIST.getCode()) {
// 禁用类型敏感词:返回温馨提示语,不调用大模型 // 禁用类型敏感词:返回提示语
log.info("检测到禁用敏感词,返回提示语,question: {}", question); log.info("检测到禁用敏感词,返回提示语");
String tipMsg = "抱歉,您输入的内容包含敏感词汇,无法为您提供服务。请调整后重新提问。"; String tipMsg = "抱歉,您输入的内容包含敏感词汇,无法为您提供服务。请调整后重新提问。";
return Flux.just(ServerSentEvent.builder(tipMsg).build()); return Flux.just(ServerSentEvent.builder(tipMsg).build());
} else if (code == ResultCode.SENSITIVE_TZ_WORDS_EXIST.getCode()) { } else if (code == ResultCode.SENSITIVE_TZ_WORDS_EXIST.getCode()) {
// 通知类型敏感词:发送企业微信通知后继续抛出异常,让前端处理产品列表 // 通知类型敏感词:发送企业微信通知,然后返回一个特殊事件告知前端展示产品列表
log.info("检测到通知类型敏感词,发送企业微信通知,question: {}", question); log.info("检测到通知类型敏感词,发送企业微信通知");
AuthUserDto authUserDto = SecurityUtil.getCurrentLoginUser(); AuthUserDto authUserDto = SecurityUtil.getCurrentLoginUser();
String userName = authUserDto.getUsername(); String userName = authUserDto.getUsername();
String params = "{\"customerName\":\"" + userName + "\"}"; String params = "{\"customerName\":\"" + userName + "\"}";
ApiSendRequest request = new ApiSendRequest(); ApiSendRequest request = new ApiSendRequest();
request.setChannelBizId("wecom_default"); request.setChannelBizId("wecom_default");
request.setChannelBizId("tpl_wecom_order"); request.setTemplateBizId("tpl_wecom_order");
request.setReceiver("zxm|Sweet"); request.setReceiver("zxm|Sweet");
request.setParams(params); request.setParams(params);
apiNotificationTaskFeignClient.send(request); apiNotificationTaskFeignClient.send(request);
// 抛出异常,前端根据code=50002调用产品列表接口
throw new BusinessException(e.getCode(), e.getMsg()); // 返回 SSE 事件,event 类型为 sensitive_notification,前端根据此事件调用产品列表接口
} else { return Flux.just(
// 其他异常继续抛出 ServerSentEvent.<String>builder()
throw e; .event("sensitive_notification")
.data("show_products")
.build()
);
} }
// 其他异常继续抛出
throw e;
} }
// 正常调用大模型流式接口 // 正常调用大模型流式接口
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment