ソースを参照

Merge branch 'master-zzby' of http://192.168.1.222:3000/jiayi/base-callcenter-web into master-zzby

闪电 10 ヶ月 前
コミット
741927f339
共有1 個のファイルを変更した121 個の追加11 個の削除を含む
  1. 121 11
      src/components/main/Navbar/cpns/aiDialog/aiDialog.vue

+ 121 - 11
src/components/main/Navbar/cpns/aiDialog/aiDialog.vue

@@ -32,6 +32,42 @@
32 32
                             <div class="aiHtml">{{item.page_content}}</div>
33 33
                         </div>
34 34
                     </div>
35
+                    <div class="conversation_item" v-if="item.direction ===3 ">
36
+                        <div class="item_ai">
37
+                            <div class="aiHtmlTit">{{item.title}}</div>
38
+                            <div class="aiHtml" v-html="item.page_content"></div>
39
+                            <div class="tools-wrap">
40
+                                <div class="item-ai-tools">
41
+                                    <div class="tools-left">
42
+                                        <div class="tool">
43
+                                                <div v-if="item.categoryname">
44
+                                                    <el-icon style="margin-right: 5px; vertical-align: -15%">
45
+                                                        <Tickets /> 
46
+                                                    </el-icon>
47
+                                                    <!-- 分类: -->
48
+                                                    <span>{{ item.categoryname }}</span>
49
+                                                </div>
50
+                                                <div v-if="item.labelname">
51
+                                                    <el-icon><Discount /></el-icon>
52
+                                                    <!-- 标签: -->
53
+                                                    <span>{{ item.labelname }}</span>
54
+                                                </div>
55
+                                                <div v-if="item.directoryname">
56
+                                                    <el-icon style="margin-right: 5px; vertical-align: -15%">
57
+                                                        <Tickets /> 
58
+                                                    </el-icon>
59
+                                                    <!-- 目录分类: -->
60
+                                                    <span>{{ item.directoryname }}</span>
61
+                                                </div>
62
+                                                
63
+                                        </div>
64
+                                    </div>
65
+
66
+                                </div>
67
+                            </div>
68
+                        </div>
69
+                    </div>
70
+
35 71
                     <div class="conversation_item" v-if="item.direction === 2 ">
36 72
                         <div class="item_ai" v-loading="item.loadingFlag">
37 73
                             <!-- v-for="(item,index) in productDetails.content && productDetails.content.split('\n')" :key="index" -->
@@ -230,7 +266,7 @@
230 266
     import aiIcon from '@/assets/images/aiIcon.png' // 默认头像
231 267
     import { getToken } from '@/utils/auth'
232 268
     import { base64data } from '@/utils/baseUrlData'
233
-    import { createPageData } from '@/api/main/system/system';
269
+    import { createPageData,getPageDetail } from '@/api/main/system/system';
234 270
     const { proxy } = getCurrentInstance();
235 271
     const drawer = ref(false)
236 272
     const props = defineProps({
@@ -244,15 +280,13 @@
244 280
         console.log('onMounted-ai')
245 281
         // getSearchDocs()
246 282
         modelData.value = quesModelData
247
-
283
+        
248 284
         if (props.text) {
249 285
             postChatText.value = props.text;
250 286
             enterHnadle();
251 287
         }
252 288
     })
253 289
 
254
-    
255
-
256 290
     watch(props , (newVal, oldVal) => {
257 291
         console.log('watch-ai', newVal, oldVal)
258 292
         if (newVal.text) {
@@ -329,7 +363,24 @@
329 363
         }
330 364
         
331 365
     }
332
-
366
+    
367
+    const knowledgeDetail = ref({})
368
+    const knowledgeText = ref('')
369
+    function sendKnowledge(docId) {
370
+        getPageDetail('/km/doc/' + docId).then((data) => {
371
+            if (data.data) {
372
+                knowledgeDetail.value = data.data;
373
+                dialogState.value = '会话中'
374
+                tipFlag.value = false
375
+                knowledgeText.value = data.data.keywords
376
+                sendChatText(3, (data.data || ''))
377
+                // getSearchDocs()
378
+            }
379
+        });
380
+    }
381
+    defineExpose({
382
+        sendKnowledge
383
+    })
333 384
     const createLog = (content) => {
334 385
         createPageData('/ai/aioperation', {
335 386
             operateType: 'DeepSeek',
@@ -359,10 +410,18 @@
359 410
     }
360 411
     const chatData = ref([])
361 412
     function sendChatText(direction, dataValue) {
362
-        const obj = {
363
-            direction,
364
-            page_content: dataValue
413
+        const obj = { direction }
414
+
415
+        if (direction === 3) {
416
+            obj.title = dataValue.title
417
+            obj.page_content = dataValue.content
418
+            obj.categoryname =  dataValue.categoryname
419
+            obj.labelname =  dataValue.labelname
420
+            obj.directoryname =  dataValue.directoryname
421
+        } else{
422
+            obj.page_content = dataValue
365 423
         }
424
+
366 425
         chatData.value.push(obj)
367 426
         
368 427
         setTimeout(() => {
@@ -417,6 +476,7 @@
417 476
     }
418 477
 
419 478
     async function getSearchDocs() {
479
+        
420 480
         let params = {}
421 481
         const obj = {
422 482
             direction:2,
@@ -439,13 +499,13 @@
439 499
 					content,
440 500
 				}, {
441 501
 					role: 'user',
442
-					content: postChatText.value,
502
+					content: postChatText.value || knowledgeText.value,
443 503
 				}],
444 504
 				stop: ['stop'],
445 505
 				stream: true,
446 506
             }
447 507
 
448
-            createLog(postChatText.value);
508
+            createLog(postChatText.value || knowledgeText.value);
449 509
             // 发送请求
450 510
             // let response = await fetch("http://192.168.1.89:7861/chat/kb_chat",
451 511
             const url = import.meta.env.VITE_APP_AI_API || 'https://open.bigmodel.cn/api/paas/v4/chat/completions'
@@ -499,6 +559,7 @@
499 559
                     try {
500 560
                         // 后端返回的流式数据一般都是以data:开头的字符,排除掉data:后就是需要的数据
501 561
                         // 具体返回结构可以跟后端约定
562
+                        knowledgeText.value = ''
502 563
                         let text = val?.replace("data:", "") || ""
503 564
                         const resultData = JSON.parse(text)
504 565
                         let resultText = resultData.choices[0].delta.content
@@ -735,6 +796,51 @@
735 796
                         word-break: break-all !important;
736 797
                         position: relative;
737 798
                     }
799
+                    .tools-wrap {
800
+                        position: relative;
801
+
802
+                        .item-ai-tools {
803
+                            display: flex;
804
+                            -ms-flex-align: center;
805
+                            align-items: center;
806
+                            -ms-flex-pack: justify;
807
+                            justify-content: space-between;
808
+                            height: 20px;
809
+                            margin-bottom: 8px;
810
+                            font-family: PingFang SC, PingFang SC;
811
+                            font-weight: 400;
812
+                            font-size: 12px;
813
+                            color: #86909C;
814
+                            padding: 0 12px;
815
+
816
+                            .tools-left {
817
+                                display: flex;
818
+                                -ms-flex-align: center;
819
+                                align-items: center;
820
+                                -ms-flex-pack: center;
821
+                                justify-content: center;
822
+
823
+                                .tool {
824
+                                    display: flex;
825
+                                    padding: 0 4px;
826
+                                    height: 20px;
827
+                                    color: #FFFFFF
828
+                                }
829
+                            }
830
+
831
+                            .tools-right {
832
+                                margin-left: 12px;
833
+                                display: flex;
834
+
835
+                                .pointer {
836
+                                    position: relative;
837
+                                    width: 20px;
838
+                                    height: 20px;
839
+                                    border-radius: 4px;
840
+                                }
841
+                            }
842
+                        }
843
+                    }
738 844
                 }
739 845
 
740 846
                 .item_ai {
@@ -744,7 +850,11 @@
744 850
                     background: #ffffff;
745 851
                     border-radius: 2px 16px 16px 16px;
746 852
                     margin-bottom: 24px;
747
-
853
+                    .aiHtmlTit{
854
+                        font-size: 16px;
855
+                        font-weight: bold;
856
+                        padding: 8px 0px 0px 12px;
857
+                    }
748 858
                     .aiHtml {
749 859
                         white-space: pre-wrap;
750 860
                         font-size: 14px;