瀏覽代碼

feat: 调整猜你想问相关

zhangyuhan 8 月之前
父節點
當前提交
1db5218e65
共有 2 個文件被更改,包括 762 次插入804 次删除
  1. 48 21
      src/views/CustomerView.vue
  2. 714 783
      yarn.lock

+ 48 - 21
src/views/CustomerView.vue

@@ -83,7 +83,7 @@ import { Container, Main, Avatar, Badge, Button, Input, Divider, Drawer } from '
 import AsideView from '@/components/aside/'
 import MessageList from '@/components/MessageList'
 import { mapState, mapMutations, mapActions, mapGetters } from 'vuex'
-import { getChartGroupInfo, robotInfo, createChatSession, getUserList, getMessageCount, closeChatSession, getWebSocketNode, aiChatFindAnswer, customerEval, joinChartGroup, createChartGroup, guessWantAsk } from '@/api/modules/'
+import { getChartGroupInfo, robotInfo, createChatSession, getUserList, getMessageCount, closeChatSession, getWebSocketNode, robotFindAnswer, customerEval, joinChartGroup, createChartGroup, guessWantAsk } from '@/api/modules/'
 import { getLink, debounce, removeHtmlStyle, setTrack } from '@/utils/'
 import CommunicateBook from '@/components/communicateBook/index'
 import GroupInfo from '@/components/group-info/'
@@ -897,27 +897,27 @@ export default {
         this.onTurnPeople(question.replace(/\s+/g, ''), '')
         return
       }
-      // const { data } = await robotFindAnswer({
-      //   question: question,
-      //   type: type,
-      //   robotEntId: this.other.userId
-      // })
-      // const content = data && data.answer ? data.answer : this.excuse.unknown // 有答案取答案,没答案取未知问题说辞
-      const { data, error_msg: msg, error_code: code } = await aiChatFindAnswer({
-        prompt: question,
-        history: this.historyQuestion,
-        href: location.origin
+      const { data, error_code: code } = await robotFindAnswer({
+        question: question,
+        type: type,
+        robotEntId: this.other.userId
       })
+      const content = data && data.answer ? data.answer : this.excuse.unknown // 有答案取答案,没答案取未知问题说辞
+      // const { data, error_msg: msg, error_code: code } = await aiChatFindAnswer({
+      //   prompt: question,
+      //   history: this.historyQuestion,
+      //   href: location.origin
+      // })
       this.historyQuestion.push(question)
       if (code === 0) {
-        const content = data?.reply ? data?.reply : msg
+        // const content = data?.reply ? data?.reply : msg
         setTimeout(() => {
           const apiParams = {
             ownType: 2,
             title: '机器人自动回复',
             content: content,
             item: 8,
-            itemType: data?.reply ? 8 : 4, // 有答案的即为知识库内容标识为8,无答案为未知问题说辞标识为4
+            itemType: data?.answer ? 8 : 4, // 有答案的即为知识库内容标识为8,无答案为未知问题说辞标识为4
             sendId: this.other.sessionId, // 发送人标识(客服发送信息时该值为会话标识,用户聊天时该值不传)
             type: 1,
             link: '',
@@ -998,9 +998,9 @@ export default {
       }
     },
     // 保存并发送公共方法
-    async onSendCommon ({ apiParams, socketParams }, isSend = true) {
+    async onSendCommon ({ apiParams, socketParams }, isSend = true, isSkip = false) {
       await this.robotOvertimeReply()
-      this.setSendCopy({ apiParams, socketParams }, isSend = true)
+      this.setSendCopy({ apiParams, socketParams }, isSend = true, null, isSkip)
       // 用户跟用户聊、群聊 不需要查询聊天状态 return
       if (this.other.userType >= 2) return
       const storage = this.userSessionBadge
@@ -1011,7 +1011,7 @@ export default {
         })
       }
     },
-    async setSendCopy ({ apiParams, socketParams }, isSend = true, num) {
+    async setSendCopy ({ apiParams, socketParams }, isSend = true, num, isSkip = false) {
       // isSend:是否通过websocket发送消息
       if (!apiParams.content) return
       const { error_code: code, data } = await this.saveMessageAction(apiParams)
@@ -1040,7 +1040,7 @@ export default {
             } catch (error) {}
           }
         }
-        if (apiParams.fool === 1) {
+        if (apiParams.fool === 1 && !isSkip) {
           this.robotAutoReply(content)
         }
         if (num === 1) {
@@ -1069,7 +1069,7 @@ export default {
       this.getUserListLastMsg(rUserId, contentType, removeHtmlStyle(content), time)
     },
     // 发送、存储文本消息
-    onSendMsg (content, data) {
+    onSendMsg (content, data, skip = false) {
       let type = 1
       if (data) {
         type = data?.type
@@ -1107,7 +1107,7 @@ export default {
         sessionId: this.other.sessionId
       }
       this.msgVal = ''
-      this.onSendCommon({ apiParams, socketParams })
+      this.onSendCommon({ apiParams, socketParams }, true, true)
     },
     // 发送、存储图片消息
     onUploadImage (data) {
@@ -1422,8 +1422,9 @@ export default {
     },
     // 选择联想问题发送客服
     chooseQuestion (item) {
-      const { question } = item
-      this.onSendMsg(removeHtmlStyle(question))
+      const { question, answer } = item
+
+      this.onSendMsg(removeHtmlStyle(question), null, true)
       // 埋点
       setTrack({
         id: 'c_social',
@@ -1435,6 +1436,32 @@ export default {
       try {
         this.$refs.chartInput.$refs?.quillEditorRef.setRangeIndex()
       } catch (error) { }
+
+      // 自动回复答案
+      if (answer) {
+        setTimeout(() => {
+          const apiParams = {
+            ownType: 2,
+            title: '猜你想问-自动回复',
+            content: answer,
+            item: 8,
+            itemType: 4, // 机器人信息
+            sendId: this.other.sessionId, // 发送人标识(客服发送信息时该值为会话标识,用户聊天时该值不传)
+            type: 1,
+            link: '',
+            fool: 2
+          }
+          const socketParams = {
+            type: 27,
+            rUserId: this.other.userId,
+            rUserType: this.other.userType,
+            contentType: 1,
+            headImg: this.autoUserInfo.img,
+            nickName: this.autoUserInfo.name
+          }
+          this.onSendCommon({ apiParams, socketParams }, true)
+        }, 200)
+      }
     },
     onCustomerText (val) {
       this.isTrick = true // 选中列表话术则跳过联想

文件差異過大導致無法顯示
+ 714 - 783
yarn.lock


部分文件因文件數量過多而無法顯示