|
@@ -40,7 +40,8 @@ import java.util.Map;
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
|
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.KEFU_CONVERSATION_NOT_EXISTS;
|
|
|
-import static cn.iocoder.yudao.module.promotion.enums.WebSocketMessageTypeConstants.*;
|
|
|
+import static cn.iocoder.yudao.module.promotion.enums.WebSocketMessageTypeConstants.KEFU_MESSAGE_ADMIN_READ;
|
|
|
+import static cn.iocoder.yudao.module.promotion.enums.WebSocketMessageTypeConstants.KEFU_MESSAGE_TYPE;
|
|
|
|
|
|
/**
|
|
|
* 客服消息 Service 实现类
|
|
@@ -125,15 +126,18 @@ public class KeFuMessageServiceImpl implements KeFuMessageService {
|
|
|
MemberUserRespDTO user = memberUserApi.getUser(kefuMessage.getSenderId());
|
|
|
KeFuMessageRespVO message =
|
|
|
BeanUtils.toBean(kefuMessage, KeFuMessageRespVO.class).setSenderAvatar(user.getAvatar());
|
|
|
- getSelf().sendAsyncMessageToMember(sendReqVO.getRelUserId(), KEFU_MESSAGE_IM, message);
|
|
|
-
|
|
|
+ /* if (sendReqVO.getSenderType() != 22) {
|
|
|
+ getSelf().sendAsyncMessageToMember(sendReqVO.getRelUserId(), KEFU_MESSAGE_IM, message);
|
|
|
+
|
|
|
+
|
|
|
+ }*/
|
|
|
|
|
|
return kefuMessage.getId();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
//@Async
|
|
|
- public Flux<String> sendStream(AppKeFuMessageSendReqVO sendReqVO) {
|
|
|
+ public Flux<KeFuMessageRespVO> sendStream(AppKeFuMessageSendReqVO sendReqVO) {
|
|
|
// 1.1 设置会话编号
|
|
|
String apiKey = DictFrameworkUtils.parseDictDataValue("ai_key", "多轮对话");
|
|
|
Map<String, Object> inputs = new HashMap<>();
|
|
@@ -146,6 +150,7 @@ public class KeFuMessageServiceImpl implements KeFuMessageService {
|
|
|
} else {
|
|
|
inputs.put("type", "其他");
|
|
|
}
|
|
|
+ Long relUserId = sendReqVO.getRelUserId();
|
|
|
inputs.put("token", sendReqVO.getToken());
|
|
|
String conversationId;
|
|
|
KeFuMessageDO kefuMessage = BeanUtils.toBean(sendReqVO, KeFuMessageDO.class);
|
|
@@ -161,11 +166,13 @@ public class KeFuMessageServiceImpl implements KeFuMessageService {
|
|
|
|
|
|
AppKeFuMessageSendReqVO aiSendReqVO = sendReqVO;
|
|
|
aiSendReqVO.setRelUserId(SecurityFrameworkUtils.getLoginUserId());
|
|
|
- aiSendReqVO.setSenderId(aiSendReqVO.getRelUserId());
|
|
|
- aiSendReqVO.setContentType(11);
|
|
|
+ aiSendReqVO.setSenderId(relUserId);
|
|
|
+ aiSendReqVO.setContentType(22);
|
|
|
+ aiSendReqVO.setSenderType(22);
|
|
|
Long aiId = sendMessage(aiSendReqVO);
|
|
|
StringBuffer contentBuffer = new StringBuffer();
|
|
|
StringBuffer contentBufferCon = new StringBuffer();
|
|
|
+ KeFuMessageRespVO message = BeanUtils.toBean(aiSendReqVO, KeFuMessageRespVO.class);
|
|
|
return aiApi.getDifyMessageStreaming(inputs,
|
|
|
SecurityFrameworkUtils.getLoginUserId().toString(),
|
|
|
apiKey, sendReqVO.getContent(), conversationId)
|
|
@@ -176,7 +183,9 @@ public class KeFuMessageServiceImpl implements KeFuMessageService {
|
|
|
log.info("进入workflow_finished阶段:" + answer);
|
|
|
if (StrUtil.isNotBlank(answer)) {
|
|
|
contentBuffer.append(answer);
|
|
|
- return Flux.just(answer);
|
|
|
+ message.setContent(answer);
|
|
|
+ message.setMessageId(response.getMessage_id());
|
|
|
+ return Flux.just(message);
|
|
|
}
|
|
|
}
|
|
|
if (response.getEvent().equals("message_end")) {
|