Przeglądaj źródła

1.新版ai处理用户信息

jzp 3 tygodni temu
rodzic
commit
97f80284c7

+ 17 - 7
fs-service/src/main/java/com/fs/fastGpt/service/impl/AiHookServiceImpl.java

@@ -663,10 +663,9 @@ public class AiHookServiceImpl implements AiHookService {
                 }
 
                 if (result.isLongText()){
-                    //新增用户信息
-                    addUserInfo(contentKh, qwExternalContacts.getId(),fastGptChatSession);
-
                     if(isNewVersion){
+                        //新增用户信息
+                        addUserInfoNew(contentKh,fastGptChatSession);
                         if ("北京卓美".equals(signProjectName) && type == 16) {
                             sendAiVoiceMsg(content, sender, uid, serverId, user);
                         } else {
@@ -675,7 +674,8 @@ public class AiHookServiceImpl implements AiHookService {
                             sendAiMsg(content,sender,uid,serverId);
                         }
                     } else {
-
+                        //新增用户信息
+                        addUserInfo(contentKh, qwExternalContacts.getId(),fastGptChatSession);
                         if (type == 16) {
                             if (user.getIsCustomerVoice() != null && user.getIsCustomerVoice() == 1) {
                                 sendAiVoiceMsg(content, sender, uid, serverId, user);
@@ -700,10 +700,10 @@ public class AiHookServiceImpl implements AiHookService {
                     }
 
                     List<String> countList = countString(content);
-                    //新增用户信息
-                    addUserInfo(contentKh, qwExternalContacts.getId(),fastGptChatSession);
                     for (String msg : countList) {
                         if(isNewVersion){
+                            //新增用户信息
+                            addUserInfoNew(contentKh,fastGptChatSession);
                             if ("北京卓美".equals(signProjectName) && type == 16) {
                                 sendAiVoiceMsg(msg,sender,uid,serverId,user);
                             } else {
@@ -712,7 +712,8 @@ public class AiHookServiceImpl implements AiHookService {
                                 sendAiMsg(msg,sender,uid,serverId);
                             }
                         } else {
-
+                            //新增用户信息
+                            addUserInfo(contentKh, qwExternalContacts.getId(),fastGptChatSession);
                             if (type == 16) {
                                 if (user.getIsCustomerVoice() != null && user.getIsCustomerVoice() == 1) {
                                     sendAiVoiceMsg(msg, sender, uid, serverId, user);
@@ -750,6 +751,15 @@ public class AiHookServiceImpl implements AiHookService {
         return R.ok();
     }
 
+    private void addUserInfoNew(String word,FastGptChatSession fastGptChatSession)  {
+        com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(word);
+        String userInfo = jsonObject.getString("userInfo");
+        FastGptChatSession chatSession = new FastGptChatSession();
+        chatSession.setSessionId(fastGptChatSession.getSessionId());
+        chatSession.setUserInfo(userInfo);
+        fastGptChatSessionMapper.updateFastGptChatSession(chatSession);
+    }
+
     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");