| | |
| | | /> |
| | | </template> |
| | | <template #content> |
| | | <!-- <a-card :class="{ chatItemAnswer: theme === 'light' }">--> |
| | | <!-- <div--> |
| | | <!-- :class="{ light: theme === 'light' }"--> |
| | | <!-- v-html="sessionDetail.content.replace(/\n/g, '<br/>')"--> |
| | | <!-- >--> |
| | | <!-- </div>--> |
| | | <!-- </a-card>--> |
| | | <a-textarea |
| | | readonly |
| | | auto-size |
| | | v-model="sessionDetail.content" |
| | | :class="{ chatItemAnswer: theme === 'light' }" |
| | | <a-card v-if="isExistTip(sessionDetail.content)"> |
| | | <div :class="{ chatItemAnswer: theme === 'light' }" |
| | | :style="{backgroundColor: theme === 'light' ? '#ffffff' : '#000000'}" style="border: none;display: inline;" v-for="(item,tipIndex) in tipMatch(sessionDetail)" |
| | | > |
| | | <span v-if="tipIndex == 0"> |
| | | {{ sessionDetail.content.substring(0, item.index) }} |
| | | <a-tooltip background-color="#3491FA" :content="getTipContent( |
| | | messagenList.reference, |
| | | index |
| | | )"> |
| | | <img style="width: 20px;height: 20px" :src="tipImage" /> |
| | | </a-tooltip> |
| | | </span> |
| | | <span v-else> |
| | | {{ sessionDetail.content.substring(item.preIndex+item.item.length, item.index) }} |
| | | <a-tooltip background-color="#3491FA" :content="getTipContent( |
| | | messagenList.reference, |
| | | index |
| | | )"> |
| | | <img style="width: 20px;height: 20px" :src="tipImage" /> |
| | | </a-tooltip> |
| | | </span> |
| | | |
| | | </div> |
| | | </a-card> |
| | | <a-card v-else> |
| | | <div :class="{ chatItemAnswer: theme === 'light' }" |
| | | :style="{ |
| | | backgroundColor: |
| | | theme === 'light' ? '#ffffff' : '#000000', |
| | | }" |
| | | style="border: none" |
| | | > |
| | | </a-textarea> |
| | | }" style="border: none"> |
| | | {{ sessionDetail.content }} |
| | | </div> |
| | | </a-card> |
| | | </template> |
| | | <!-- <div>{{ sessionDetail.role === 'assistant' }}</div> --> |
| | | <template #actions> |
| | |
| | | import pdfImg3 from '@/assets/session/execl.png'; |
| | | import pdfImg4 from '@/assets/session/icon-txt.png'; |
| | | import pdfImg5 from '@/assets/session/txt.png'; |
| | | import tipImage from '@/assets/session/tip.png'; |
| | | import { number } from "@intlify/core-base"; |
| | | |
| | | // const url = ref('../../assets/session/PDF.png'); |
| | | |
| | |
| | | } |
| | | }; |
| | | let dataItem = []; |
| | | const getTxt = (data, role, message, index) => { |
| | | const isExistTip=(message:string):boolean=>{ |
| | | if (/##[0-9]\$\$/.test(message)) { |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | const tipMatch = (session: any): any[] => { |
| | | //match session.content中的##[0-9]$$的索引 |
| | | let indexs: any[] = []; |
| | | let preTip=0; |
| | | session.content.match(/##([0-9]+)\$\$/g)?.map((item) => { |
| | | let i = session.content.indexOf(item); |
| | | indexs.push({ index: i, item: item, preIndex: preTip }); |
| | | preTip = i; |
| | | }); |
| | | return indexs; |
| | | } |
| | | |
| | | const getTxt = (data, role, message, index) => { |
| | | if (isExistTip(message)) { |
| | | if (role == 'assistant' && index) { |
| | | let i = index / 2 - 1 > 0 ? index / 2 - 1 : 0; |
| | | dataItem = data[i].doc_aggs; |
| | |
| | | return dataItem; |
| | | }; |
| | | |
| | | const getTipContent = (data, index): string => { |
| | | let maxSimilarityContent = ""; |
| | | let i = index / 2 - 1 > 0 ? index / 2 - 1 : 0; |
| | | let maxSimilarity = 0; |
| | | data[i].chunks.forEach((chunk) => { |
| | | if (chunk.similarity > maxSimilarity) { |
| | | maxSimilarity = chunk.similarity; |
| | | maxSimilarityContent = chunk.content_with_weight; |
| | | } |
| | | } |
| | | ); |
| | | return maxSimilarityContent; |
| | | }; |
| | | |
| | | const clickHref = (item) => { |
| | | // return Message.warning('暂无法查看'); |
| | | // window.open(`/api/v1/document/get/${item.doc_id}`, '_blank'); |