|
|
@@ -615,7 +615,7 @@ public class AiHookServiceImpl implements AiHookService {
|
|
|
return R.ok();
|
|
|
}
|
|
|
String contentKh = result.getChoices().get(0).getMessage().getContent();
|
|
|
- String finalContentKh = null;
|
|
|
+ /*String finalContentKh = null;
|
|
|
JSONArray jsonArray = JSON.parseArray(contentKh);
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = (com.alibaba.fastjson.JSONObject)jsonArray.get(i);
|
|
|
@@ -626,8 +626,9 @@ public class AiHookServiceImpl implements AiHookService {
|
|
|
}
|
|
|
}
|
|
|
Gson gson = new Gson();
|
|
|
- contentKh = finalContentKh;
|
|
|
- FastGptChatConversation fastGptChatConversation = gson.fromJson(finalContentKh, FastGptChatConversation.class);
|
|
|
+ contentKh = finalContentKh;*/
|
|
|
+ Gson gson = new Gson();
|
|
|
+ FastGptChatConversation fastGptChatConversation = gson.fromJson(contentKh, FastGptChatConversation.class);
|
|
|
String content = fastGptChatConversation.getAiContent();
|
|
|
//计算token
|
|
|
List<ChatDetailTStreamFResult.ResponseNode> responseData = result.getResponseData();
|
|
|
@@ -657,23 +658,27 @@ public class AiHookServiceImpl implements AiHookService {
|
|
|
if (result.isLongText()){
|
|
|
//新增用户信息
|
|
|
addUserInfoNew(contentKh, qwExternalContacts.getId(),fastGptChatSession);
|
|
|
- if (type==16){
|
|
|
+ //发送图片消息
|
|
|
+ sendImgMsg(contentKh,sender,uid,serverId);
|
|
|
+ /*if (type==16){
|
|
|
sendAiVoiceMsg(content,sender,uid,serverId,user);
|
|
|
- }else {
|
|
|
+ }else {*/
|
|
|
sendAiMsg(content,sender,uid,serverId);
|
|
|
- }
|
|
|
+ //}
|
|
|
|
|
|
}else {
|
|
|
|
|
|
List<String> countList = countString(content);
|
|
|
//新增用户信息
|
|
|
addUserInfoNew(contentKh, qwExternalContacts.getId(),fastGptChatSession);
|
|
|
+ //发送图片消息
|
|
|
+ sendImgMsg(contentKh,sender,uid,serverId);
|
|
|
for (String msg : countList) {
|
|
|
- if (type==16){
|
|
|
+ /*if (type==16){
|
|
|
sendAiVoiceMsg(msg,sender,uid,serverId,user);
|
|
|
- }else {
|
|
|
+ }else {*/
|
|
|
sendAiMsg(msg,sender,uid,serverId);
|
|
|
- }
|
|
|
+ //}
|
|
|
try {
|
|
|
Thread.sleep(500);
|
|
|
} catch (InterruptedException e) {
|
|
|
@@ -699,6 +704,39 @@ public class AiHookServiceImpl implements AiHookService {
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
+ private void sendImgMsg(String contentKh, Long sender, String uuid, Long serverId) {
|
|
|
+ com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(contentKh);
|
|
|
+ JSONArray imgUrls = jsonObject.getJSONArray("imgUrl");
|
|
|
+
|
|
|
+
|
|
|
+ if(imgUrls != null && !imgUrls.isEmpty()){
|
|
|
+ WxWorkResponseDTO<WxwUploadCdnLinkImgRespDTO> dto = new WxWorkResponseDTO<>();
|
|
|
+ for (Object imgUrl : imgUrls) {
|
|
|
+ //1.上传cdn网络图片
|
|
|
+ if(imgUrl != null){
|
|
|
+ String imgUrlString = imgUrl.toString();
|
|
|
+ WxwUploadCdnLinkImgDTO wxwUploadCdnLinkImgDTO = new WxwUploadCdnLinkImgDTO();
|
|
|
+ wxwUploadCdnLinkImgDTO.setUuid(uuid);
|
|
|
+ wxwUploadCdnLinkImgDTO.setUrl(imgUrlString);
|
|
|
+ dto = wxWorkService.uploadCdnLinkImg(wxwUploadCdnLinkImgDTO,serverId);
|
|
|
+ }
|
|
|
+ //图片上传成功后再发送图片
|
|
|
+ if("成功".equals(dto.getErrmsg()) && imgUrl != null){
|
|
|
+ WxwUploadCdnLinkImgRespDTO imgRespDTO = dto.getData();
|
|
|
+ WxwSendCDNImgMsgDTO wxwSendCDNImgMsgDTO = new WxwSendCDNImgMsgDTO();
|
|
|
+ wxwSendCDNImgMsgDTO.setSend_userid(sender);
|
|
|
+ wxwSendCDNImgMsgDTO.setUuid(uuid);
|
|
|
+ wxwSendCDNImgMsgDTO.setIsRoom(false);
|
|
|
+ wxwSendCDNImgMsgDTO.setCdnkey(imgRespDTO.getCdn_key());
|
|
|
+ wxwSendCDNImgMsgDTO.setAeskey(imgRespDTO.getAes_key());
|
|
|
+ wxwSendCDNImgMsgDTO.setMd5(imgRespDTO.getMd5());
|
|
|
+ wxwSendCDNImgMsgDTO.setFileSize(imgRespDTO.getSize());
|
|
|
+ wxWorkService.SendCDNImgMsg(wxwSendCDNImgMsgDTO, serverId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据发送者id设置用户是否为首次回复
|
|
|
* @param sender 发送者id
|
|
|
@@ -1540,7 +1578,7 @@ public class AiHookServiceImpl implements AiHookService {
|
|
|
|
|
|
//添加关键词
|
|
|
addPromptWordNew(messageList,msgC,qwExternalContactsId,role,fastGptChatSession);
|
|
|
- R r = chatService.initiatingTakeChat(param, "http://1.95.196.10:3000/api/", appKey);
|
|
|
+ R r = chatService.initiatingTakeChat(param, "http://129.28.170.206:3000/api/", appKey);
|
|
|
Object data1 = r.get("data");
|
|
|
if(!(data1 instanceof KnowledgeBaseResult)){
|
|
|
ChatDetailTStreamFResult data = (ChatDetailTStreamFResult) r.get("data");
|
|
|
@@ -1635,12 +1673,13 @@ public class AiHookServiceImpl implements AiHookService {
|
|
|
Integer sendType = msg.getSendType();
|
|
|
String content = msg.getContent();
|
|
|
if(sendType!=1){
|
|
|
- if (content!=null&&content.length()>150){
|
|
|
+ if (content!=null&&content.length()>500){
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
history.put(sendType==1?"user":"ai",content);
|
|
|
}
|
|
|
+ conversation.setHistory(history);
|
|
|
}
|
|
|
|
|
|
if (count!=null&& !count.isEmpty()){
|