合并分支:origin/knowledge-mining',解决冲突

This commit is contained in:
wu.jifen
2025-07-11 16:26:02 +08:00
11 changed files with 986 additions and 152 deletions

View File

@@ -28,6 +28,15 @@ export function extractEmbedding(data) {
})
}
// 上传到知识库 - 拆分和题词内容
export function splitAndExtractEmbedding(data) {
return request({
url: getUrl(`/datasetDocumentEx/splitAndExtract/embedding`),
method: 'post',
data
})
}
// 上传到知识库 - 原文件
export function directEmbedding(data) {
return request({
@@ -72,3 +81,12 @@ export function extractSegmentEstimate(data) {
data
})
}
// 分段预览-拆分和题词题词内容
export function splitAndExtractSegmentEstimate(data) {
return request({
url: getUrl(`/datasetDocumentEx/splitAndExtract/segment_estimate`),
method: 'post',
data
})
}

View File

@@ -9,6 +9,7 @@ export function docManageDataset(data) {
data
})
}
//单一知识库详情
export function getDatasetById(params) {
return request({
@@ -18,6 +19,7 @@ export function getDatasetById(params) {
noLoading: true
})
}
// 知识库内容修改
export function datasetUpdate(data) {
return request({
@@ -27,6 +29,7 @@ export function datasetUpdate(data) {
noLoading: true
})
}
// 知识库新增
export function datasetCreate(data) {
return request({
@@ -53,6 +56,7 @@ export function datasetDelete(data) {
method: 'delete'
})
}
export function datasetsExPages(data) {
return request({
url: getUrl(`/datasetDocumentEx/page`),
@@ -77,6 +81,7 @@ export function minerUBbox(params) {
params: params
})
}
//minerU 重试
export function minerURetry(params) {
return request({
@@ -86,6 +91,7 @@ export function minerURetry(params) {
noLoading: true
})
}
//minerU 获取文档处理状态
export function minerUQuery(params) {
return request({
@@ -95,6 +101,7 @@ export function minerUQuery(params) {
noLoading: true
})
}
//minerU 获取markdown
export function minerUMarkDown(params) {
return getUrl(`/document/mineru/md?documentId=${params.documentId}`)
@@ -112,6 +119,7 @@ export function minerUMarkDownUpdate(data) {
data
})
}
// 规则分页
export function getRulesPage(data) {
return request({
@@ -120,6 +128,7 @@ export function getRulesPage(data) {
data
})
}
export function getRulesList(data) {
return request({
url: getUrl(`/rules/list`),
@@ -127,6 +136,7 @@ export function getRulesList(data) {
data
})
}
// 拆分规则-新增
export function addRuleSplit(data) {
return request({
@@ -135,6 +145,7 @@ export function addRuleSplit(data) {
data
})
}
// 拆分规则-详情
export function getRuleDetail(id) {
return request({
@@ -142,6 +153,7 @@ export function getRuleDetail(id) {
method: 'get'
})
}
// 拆分规则-编辑
export function updateRuleSplit(data) {
return request({
@@ -150,6 +162,7 @@ export function updateRuleSplit(data) {
data
})
}
// 拆分规则-下一步校验
export function execSplit(data) {
return request({
@@ -158,6 +171,7 @@ export function execSplit(data) {
data
})
}
// 拆分结果预览
export function splitResultPreview(params) {
return request({
@@ -166,6 +180,7 @@ export function splitResultPreview(params) {
params: params
})
}
// 题词-新增
export function addRuleExtract(data) {
return request({
@@ -174,6 +189,7 @@ export function addRuleExtract(data) {
data
})
}
// 题词-编辑
export function updateRuleExtractSplit(data) {
return request({
@@ -182,6 +198,7 @@ export function updateRuleExtractSplit(data) {
data
})
}
// 题词-下一步校验
export function execExtract(data) {
return request({
@@ -240,6 +257,7 @@ export function uploadFileByCustom(data) {
}
})
}
/*一键上传*/
export function directEmbedding(data) {
return request({
@@ -274,6 +292,7 @@ export function datasetQuerySegments(data) {
// 知识文档详情查询包含json的题词和拆分规则
export function datasetDocumentEx(data) {
return request({
noLoading: true,
url: getUrl(`/datasetDocumentEx/query`),
method: 'get',
params: data
@@ -288,6 +307,7 @@ export function getTaskDetail(params) {
params
})
}
// 知识库文件删除
export function datasetQueryDelete(data) {
return request({
@@ -323,6 +343,7 @@ export function getMd_info(params) {
noLoading: true
})
}
export function mdIndex(params) {
return request({
url: getUrl(`/document/mineru/md`),
@@ -341,6 +362,7 @@ export function embedding(data) {
data
})
}
// 查询知识库元数据列表
export function getMetadataList(data) {
return request({
@@ -350,6 +372,7 @@ export function getMetadataList(data) {
noLoading: true
})
}
// 新增元数据
export function createMetadata(data) {
return request({
@@ -358,6 +381,7 @@ export function createMetadata(data) {
data
})
}
// 修改元数据
export function updateMetadata(data) {
return request({
@@ -366,6 +390,7 @@ export function updateMetadata(data) {
data
})
}
// 删除元数据
export function deleteMetadata(data) {
return request({
@@ -374,6 +399,7 @@ export function deleteMetadata(data) {
data
})
}
// 启用/禁用内置元数据
export function builtInEnableMetadata(data) {
return request({
@@ -382,6 +408,7 @@ export function builtInEnableMetadata(data) {
data
})
}
// 查询文档元数据列表
export function getMetaDataDocList(data) {
return request({
@@ -390,6 +417,7 @@ export function getMetaDataDocList(data) {
data
})
}
// 新增文档元数据
export function addMetaDataDoc(data) {
return request({
@@ -398,6 +426,7 @@ export function addMetaDataDoc(data) {
data
})
}
// 删除文档元数据
export function deleteMetaDataDoc(data) {
return request({
@@ -406,6 +435,7 @@ export function deleteMetaDataDoc(data) {
data
})
}
// 编辑文档元数据
export function updateMetaDataDoc(data) {
return request({
@@ -414,6 +444,7 @@ export function updateMetaDataDoc(data) {
data
})
}
export function uploadImage(data) {
return request({
url: getUrl(`/image/upload`),
@@ -439,6 +470,7 @@ export function segmentDelete(data) {
params: data
})
}
// 新增分段
export function segmentCreate(data) {
return request({
@@ -453,6 +485,7 @@ export function segmentTemplate(model) {
// model 分别时 qa general
return getUrl(`/template/download/${model}`)
}
// 导入分段
export function importSegment(data) {
return request({
@@ -461,6 +494,7 @@ export function importSegment(data) {
data
})
}
// 导出分段
export function exportSegment(data) {
@@ -478,6 +512,7 @@ export function switchStatus(data) {
noLoading: true
})
}
// 知识库关联智能体
export function relatedApps(data) {
return request({
@@ -486,7 +521,17 @@ export function relatedApps(data) {
params: data
})
}
// 下载知识原文件
export function downloadOriginalFile(data) {
return getUrl(`/datasetDocumentEx/download/original_file?documentId=` + data)
}
// 获取知识库里未完成的知识挖掘数据
export function getUnfinishedExtract(data) {
return request({
url: getUrl(`/datasetDocumentEx/unfinishedExtract?datasetId=` + data),
method: 'get',
noLoading: true
})
}

View File

@@ -367,6 +367,7 @@ export default {
// }
},
changePageDown(type) {
this.changeTab(0)
if (this.page <= 0) {
return false
}
@@ -396,6 +397,7 @@ export default {
},
changePageUp(type) {
this.changeTab(0)
if (this.page >= this.mdJsons.length) {
return false
}
@@ -580,6 +582,7 @@ export default {
},
// 保存markdown
async saveMarkDown() {
this.changeTab(0)
let promises = []
this.mdJsons.map(item => {

View File

@@ -1,5 +1,6 @@
import layout from '@/views/app/layout/layout.vue'
import redirect from '@/views/app/redirect/index.vue'
const home = () => import('@/views/app/Home')
export default [
@@ -99,7 +100,11 @@ export default [
icon: 'el-icon-s-home'
}
},
{
path: '/knowledge/detail/customWord',
name: 'custom-word',
component: () => import('@/views/knowledge/detail/components/words/WordIndex.vue')
},
{
path: '/knowledge/reviewKnowledge',
name: 'knowledge-review-knowledge',

View File

@@ -52,13 +52,13 @@
@click="handleConfirm"
>下一步</el-button
>
<el-button
size="medium"
type="primary"
class="line-button"
@click="emitKnowledgeDataset"
>直接上传至知识库</el-button
>
<!-- <el-button-->
<!-- size="medium"-->
<!-- type="primary"-->
<!-- class="line-button"-->
<!-- @click="emitKnowledgeDataset"-->
<!-- >直接上传至知识库</el-button-->
<!-- >-->
</span>
</r-dialog>
</div>

View File

@@ -5,6 +5,7 @@
title="题词结果预览"
:visible.sync="visible"
width="700px"
@update:visible='handleClose'
:close-on-click-modal="false"
>
<div class="preview-content">

View File

@@ -1,75 +1,145 @@
<template>
<div class="splitConfig mt20">
<ul class="flex">
<!-- 自动题词 -->
<li
class="flex"
:class="activeIndex === index ? 'active' : ''"
v-for="(item, index) in splitOptions"
:key="index"
@click="handleClick(index)"
>
<div>
<svg
v-if="index === 0"
t="1744335709188"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="2464"
width="32"
height="32"
>
<path
d="M933.868272 511.691752a140.807706 140.807706 0 0 1 90.131728-131.067068 525.562914 525.562914 0 0 0-57.334136-138.64997 139.882962 139.882962 0 0 1-184.948826-184.948826A525.562914 525.562914 0 0 0 643.067068 0a140.376159 140.376159 0 0 1-262.134136 0A525.562914 525.562914 0 0 0 242.282962 57.334136a139.882962 139.882962 0 0 1-184.948826 184.948826A506.698134 506.698134 0 0 0 0 380.932932a140.376159 140.376159 0 0 1 0 262.134136 525.562914 525.562914 0 0 0 57.334136 138.64997 139.882962 139.882962 0 0 1 184.948826 184.948826 525.562914 525.562914 0 0 0 138.64997 57.334136 140.376159 140.376159 0 0 1 262.134136 0 525.562914 525.562914 0 0 0 138.64997-57.334136 139.882962 139.882962 0 0 1 184.948826-184.948826 506.698134 506.698134 0 0 0 57.334136-138.64997A140.807706 140.807706 0 0 1 933.868272 511.691752zM511.691752 652.437809A140.437809 140.437809 0 1 1 652.437809 511.691752 140.499458 140.499458 0 0 1 511.691752 652.437809z"
fill="#1D85ED"
p-id="2465"
></path>
</svg>
<svg
v-if="index === 1"
t="1744335834635"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="7994"
width="32"
height="32"
>
<path
d="M746 181.1c10.3 0 19.4 6.1 23.3 15.6l1 2.3 1.2 2.2 110.4 210c2.9 8.6 0.9 18.3-5.3 25l-0.6 0.7-0.6 0.7-344.5 401.9c-6.4 6.7-14.1 7.7-18.2 7.7s-11.7-1-18.2-7.7L150.1 437.6l-0.6-0.7-0.6-0.7c-6.2-6.8-8.2-16.4-5.3-25l110.4-210 1.2-2.2 1-2.3c3.9-9.5 13.1-15.6 23.3-15.6H746m0-54.6H279.4c-32.3 0-61.4 19.5-73.8 49.3L93.8 388.7c-11.9 28.7-6 61.6 14.9 84.4l345.2 402.7c15.8 17.3 37.3 25.9 58.9 25.9 21.5 0 43-8.6 58.9-25.9l345.2-402.7c20.9-22.9 26.8-55.8 14.9-84.4l-112-212.9c-12.3-29.8-41.5-49.3-73.8-49.3z"
p-id="7995"
fill="#d81e06"
></path>
<path
d="M513.9 524.6c-19.1 0-37.5-8.1-50.4-22.2l-97.7-106.7c-10.2-11.1-9.4-28.4 1.7-38.5 11.1-10.2 28.4-9.4 38.5 1.7l97.7 106.7c3.6 3.9 7.9 4.5 10.2 4.5 2.3 0 6.6-0.6 10.2-4.5l95.5-104.2c10.2-11.1 27.4-11.9 38.5-1.7 11.1 10.2 11.9 27.4 1.7 38.5l-95.5 104.2c-13 14.1-31.3 22.2-50.4 22.2z"
p-id="7996"
fill="#d81e06"
></path>
</svg>
</div>
<div class="block">
<h3>{{ item.title }}</h3>
<p class="tips">{{ item.description }}</p>
<p v-if="item.tip" class="tips">{{ item.tip }}</p>
</div>
</li>
</ul>
<!-- 弹窗组件 -->
<custom-split-dialog class="active" ref="customTable">
</custom-split-dialog>
<div class="splitConfig ">
<div v-if="!isRedig && digRes.length" style='overflow: auto'>
<div class="preview-content">
<template v-if="digRes && digRes.length > 0">
<!-- <r-table-->
<!-- :columns="columns"-->
<!-- :data="digRes"-->
<!-- :deletion="false"-->
<!-- ></r-table>-->
<!-- <div :key="index" v-for="(item, index) in digRes">
<li>{{ item.attribute }} {{ item.attributeContent }}</li>
<li>{{ item.originalContent }}</li>
</div> -->
<div v-for="(item, index) in digRes" :key="index" class="digRes-item">
<div class="kv-line">
<span class="kv-key">{{ item.attribute }}</span>
<span class="kv-sep"></span>
<span class="kv-value" v-if="!isEdit">{{
item.attributeContent
}}</span>
<el-input
v-else
v-model="item.attributeContent"
size="small"
style="width: 80%; display: inline-block;"
/>
</div>
<div class="origin-line">
<span class="origin-label">原始段落</span>
<span class="origin-content">{{ item.originalContent }}</span>
</div>
</div>
</template>
<el-empty
v-else-if="!extractResults || extractResults.length === 0"
description="暂无题词结果"
></el-empty>
</div>
</div>
<div v-else>
<ul class="flex">
<!-- 自动题词 -->
<li
class="flex"
:class="activeIndex === index ? 'active' : ''"
v-for="(item, index) in splitOptions"
:key="index"
@click="handleClick(index)"
>
<div>
<svg
v-if="index === 0"
t="1744335709188"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="2464"
width="32"
height="32"
>
<path
d="M933.868272 511.691752a140.807706 140.807706 0 0 1 90.131728-131.067068 525.562914 525.562914 0 0 0-57.334136-138.64997 139.882962 139.882962 0 0 1-184.948826-184.948826A525.562914 525.562914 0 0 0 643.067068 0a140.376159 140.376159 0 0 1-262.134136 0A525.562914 525.562914 0 0 0 242.282962 57.334136a139.882962 139.882962 0 0 1-184.948826 184.948826A506.698134 506.698134 0 0 0 0 380.932932a140.376159 140.376159 0 0 1 0 262.134136 525.562914 525.562914 0 0 0 57.334136 138.64997 139.882962 139.882962 0 0 1 184.948826 184.948826 525.562914 525.562914 0 0 0 138.64997 57.334136 140.376159 140.376159 0 0 1 262.134136 0 525.562914 525.562914 0 0 0 138.64997-57.334136 139.882962 139.882962 0 0 1 184.948826-184.948826 506.698134 506.698134 0 0 0 57.334136-138.64997A140.807706 140.807706 0 0 1 933.868272 511.691752zM511.691752 652.437809A140.437809 140.437809 0 1 1 652.437809 511.691752 140.499458 140.499458 0 0 1 511.691752 652.437809z"
fill="#1D85ED"
p-id="2465"
></path>
</svg>
<svg
v-if="index === 1"
t="1744335834635"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="7994"
width="32"
height="32"
>
<path
d="M746 181.1c10.3 0 19.4 6.1 23.3 15.6l1 2.3 1.2 2.2 110.4 210c2.9 8.6 0.9 18.3-5.3 25l-0.6 0.7-0.6 0.7-344.5 401.9c-6.4 6.7-14.1 7.7-18.2 7.7s-11.7-1-18.2-7.7L150.1 437.6l-0.6-0.7-0.6-0.7c-6.2-6.8-8.2-16.4-5.3-25l110.4-210 1.2-2.2 1-2.3c3.9-9.5 13.1-15.6 23.3-15.6H746m0-54.6H279.4c-32.3 0-61.4 19.5-73.8 49.3L93.8 388.7c-11.9 28.7-6 61.6 14.9 84.4l345.2 402.7c15.8 17.3 37.3 25.9 58.9 25.9 21.5 0 43-8.6 58.9-25.9l345.2-402.7c20.9-22.9 26.8-55.8 14.9-84.4l-112-212.9c-12.3-29.8-41.5-49.3-73.8-49.3z"
p-id="7995"
fill="#d81e06"
></path>
<path
d="M513.9 524.6c-19.1 0-37.5-8.1-50.4-22.2l-97.7-106.7c-10.2-11.1-9.4-28.4 1.7-38.5 11.1-10.2 28.4-9.4 38.5 1.7l97.7 106.7c3.6 3.9 7.9 4.5 10.2 4.5 2.3 0 6.6-0.6 10.2-4.5l95.5-104.2c10.2-11.1 27.4-11.9 38.5-1.7 11.1 10.2 11.9 27.4 1.7 38.5l-95.5 104.2c-13 14.1-31.3 22.2-50.4 22.2z"
p-id="7996"
fill="#d81e06"
></path>
</svg>
</div>
<div class="block">
<h3>{{ item.title }}</h3>
<p class="tips">{{ item.description }}</p>
<p v-if="item.tip" class="tips">{{ item.tip }}</p>
</div>
</li>
</ul>
<!-- 弹窗组件 -->
<custom-split-dialog class="active" ref="customTable">
</custom-split-dialog>
<!-- 添加题词预览组件 -->
<extract-preview
:visible.sync="previewVisible"
:extract-results="extractResults"
:is-auto-extract="activeIndex === 0"
:loading="previewLoading"
:documentList="documentList"
@confirm="handlePreviewConfirm"
/>
<!-- 添加题词预览组件 -->
<extract-preview
style="z-index: 2010"
:visible.sync="previewVisible"
:extract-results="extractResults"
:is-auto-extract="activeIndex === 0"
:loading="previewLoading"
:documentList="documentList"
@confirm="handlePreviewConfirm"
/>
</div>
<div
class="card-bottom text-right mt10"
>
<el-button v-if="!isEdit" type="primary" size="medium" @click="handleEdit"
>编辑</el-button
>
<el-button v-else type="primary" size="medium" @click="handleSave"
>保存</el-button
>
<el-button v-if="isEdit" size="medium" @click="handleCancel"
>取消</el-button
>
<el-button type="primary" size="medium" @click="redig"
>重新挖掘</el-button
>
<el-button
type="primary"
size="medium"
@click="nextStep(documentExtractId, '3')"
>直接上传至知识库
</el-button>
<el-button
type="primary"
size="medium"
@click="nextStep(documentExtractId, '4')"
>结合拆分内容上传至知识库</el-button
>
</div>
</div>
</template>
@@ -78,6 +148,7 @@ import CustomSplitDialog from './CustomWords.vue'
import ExtractPreview from './ExtractPreview.vue'
import {
execExtract,
extractUpdate,
getExtractResultList,
saveContentToDocument
} from '@/api/generatedApi'
@@ -98,26 +169,35 @@ export default {
splitOptions: [
{
icon: 'el-icon-setting',
title: '自动题词',
title: '立即挖掘',
description:
'使用系统默认的题词方式,适合新手或紧急任务,直接使用系统预设题词规则处理文本。',
tip: '提示:首次使用时建议先用自动题词测试效果,再决定是否调整。'
},
{
icon: 'el-icon-medal',
title: '自定义题词',
title: '自定义规则',
description:
'使用自定义题词方式可以根据具体需求灵活调整文本分割逻辑。',
tip: '但需要权衡灵活性与复杂度,需要用户具备一定的题词经验。'
}
],
documentId: ''
isRedig: false,
// 题词结果
digRes: [],
documentId: '',
isEdit: false,
digResBackup: []
}
},
props: {
documentList: {
type: Array,
default: () => []
},
documentExtractId: {
type: String,
default: () => ''
}
},
watch: {},
@@ -174,19 +254,19 @@ export default {
// 获取题词结果列表 - 修改后的方法
async getExtractResultOperation(documentId) {
if (documentId) {
this.documentId = documentId
this.documentId = this.documentExtractId
}
this.previewLoading = true
const params = { documentId }
// this.previewLoading = true
const params = { documentId: this.documentExtractId }
const res = await getExtractResultList(params)
if (res.content.result !== '0') {
throw new Error(res.content.resultMessage || '获取题词结果失败')
}
const results = res.content.content || []
this.digRes = res.content.content || []
// 显示预览弹窗
this.showExtractPreview(results)
// this.showExtractPreview(results)
},
// 处理预览确认
handlePreviewConfirm(extractResults) {
@@ -221,44 +301,120 @@ export default {
},
// 主方法
nextStep(documentId) {
async nextStep(documentId, active) {
this.documentId = documentId
return new Promise(async (resolve, reject) => {
try {
// 1. 执行题词
const params = this.buildExecExtractParams(documentId)
this.execExtractOperation(params).then(async res => {
if (res) {
// await this.getExtractResultOperation(documentId)
// 显示预览弹窗
this.showExtractPreview(res)
}
})
} catch (error) {
console.error('题词操作失败:', error)
reject({
success: false,
message: error.message || '题词操作失败'
})
this.$router.push({
path: '/knowledge/detail/create',
query: {
...this.$route.query,
documentId: this.documentId,
activeLevel: 2,
active: active
}
})
// return new Promise(async (resolve, reject) => {
// try {
// // 1. 执行题词
// const params = this.buildExecExtractParams(documentId)
// this.execExtractOperation(params).then(async res => {
// if (res) {
// await this.getExtractResultOperation(documentId)
// // 显示预览弹窗
// // this.showExtractPreview(res)
// }
// })
// } catch (error) {
// console.error('题词操作失败:', error)
// reject({
// success: false,
// message: error.message || '题词操作失败'
// })
// }
// })
},
redig() {
this.$router.push({
name: 'custom-word',
query: { ...this.$router.query, documentId: this.documentExtractId }
})
},
handleEdit() {
this.isEdit = true
// 深拷贝一份备份
this.digResBackup = JSON.parse(JSON.stringify(this.digRes))
},
handleSave() {
this.isEdit = false
let params = {
documentId: this.documentExtractId,
resultDTOList: this.digRes.map(item => ({
id: item.id,
attribute: item.attribute,
attributeContent: item.attributeContent
}))
}
extractUpdate(params).then(res => {
if (res) {
this.$message.success('保存成功')
}
})
},
handleCancel() {
this.isEdit = false
// 恢复原内容
this.digRes = JSON.parse(JSON.stringify(this.digResBackup))
}
},
created() {},
created() {
this.getExtractResultOperation()
},
mounted() {},
computed: {}
computed: {
columns: vm => {
return [
{
prop: 'attribute',
label: '属性',
width: 90
},
{
prop: 'attributeContent',
label: '题词内容',
render: (h, p) => {
return h('el-input', {
props: {
value: p.row.attributeContent,
size: 'medium',
disabled: !vm.isEdit
},
on: {
input: value => {
p.row.attributeContent = value
}
}
})
}
}
]
}
}
}
</script>
<style scoped lang="scss">
@import '@/assets/sass/renderSass/theme.scss';
.splitConfig {
display: flex;
flex-direction: column;
height: calc(100%);
.title {
font-size: 20px;
margin: 10px 0;
font-weight: bold;
}
ul {
list-style-type: none;
padding: 10px;
@@ -276,17 +432,21 @@ export default {
font-size: 14px;
color: #666;
}
.block {
margin-left: 20px;
h3 {
margin-bottom: 20px;
font-size: 16px;
color: #333;
}
.tips {
color: #9e9e9e;
}
}
&.active {
border: 1px solid var(--color-primary);
//background: #fefefe;
@@ -304,4 +464,30 @@ export default {
}
}
}
.digRes-item {
margin-bottom: 16px;
padding: 12px;
border: 1px solid #eee;
border-radius: 6px;
background: #fafbfc;
}
.kv-line {
font-weight: bold;
font-size: 15px;
margin-bottom: 6px;
}
.kv-key {
color: #1d85ed;
}
.kv-sep {
margin: 0 4px;
}
.origin-line {
color: #666;
font-size: 14px;
}
.origin-label {
color: #999;
}
</style>

View File

@@ -0,0 +1,396 @@
<template>
<div class="render-container">
<div class="splitConfig mt20">
<div>
<ul class="flex">
<!-- 自动题词 -->
<li
class="flex"
:class="activeIndex === index ? 'active' : ''"
v-for="(item, index) in splitOptions"
:key="index"
@click="handleClick(index)"
>
<div>
<svg
v-if="index === 0"
t="1744335709188"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="2464"
width="32"
height="32"
>
<path
d="M933.868272 511.691752a140.807706 140.807706 0 0 1 90.131728-131.067068 525.562914 525.562914 0 0 0-57.334136-138.64997 139.882962 139.882962 0 0 1-184.948826-184.948826A525.562914 525.562914 0 0 0 643.067068 0a140.376159 140.376159 0 0 1-262.134136 0A525.562914 525.562914 0 0 0 242.282962 57.334136a139.882962 139.882962 0 0 1-184.948826 184.948826A506.698134 506.698134 0 0 0 0 380.932932a140.376159 140.376159 0 0 1 0 262.134136 525.562914 525.562914 0 0 0 57.334136 138.64997 139.882962 139.882962 0 0 1 184.948826 184.948826 525.562914 525.562914 0 0 0 138.64997 57.334136 140.376159 140.376159 0 0 1 262.134136 0 525.562914 525.562914 0 0 0 138.64997-57.334136 139.882962 139.882962 0 0 1 184.948826-184.948826 506.698134 506.698134 0 0 0 57.334136-138.64997A140.807706 140.807706 0 0 1 933.868272 511.691752zM511.691752 652.437809A140.437809 140.437809 0 1 1 652.437809 511.691752 140.499458 140.499458 0 0 1 511.691752 652.437809z"
fill="#1D85ED"
p-id="2465"
></path>
</svg>
<svg
v-if="index === 1"
t="1744335834635"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="7994"
width="32"
height="32"
>
<path
d="M746 181.1c10.3 0 19.4 6.1 23.3 15.6l1 2.3 1.2 2.2 110.4 210c2.9 8.6 0.9 18.3-5.3 25l-0.6 0.7-0.6 0.7-344.5 401.9c-6.4 6.7-14.1 7.7-18.2 7.7s-11.7-1-18.2-7.7L150.1 437.6l-0.6-0.7-0.6-0.7c-6.2-6.8-8.2-16.4-5.3-25l110.4-210 1.2-2.2 1-2.3c3.9-9.5 13.1-15.6 23.3-15.6H746m0-54.6H279.4c-32.3 0-61.4 19.5-73.8 49.3L93.8 388.7c-11.9 28.7-6 61.6 14.9 84.4l345.2 402.7c15.8 17.3 37.3 25.9 58.9 25.9 21.5 0 43-8.6 58.9-25.9l345.2-402.7c20.9-22.9 26.8-55.8 14.9-84.4l-112-212.9c-12.3-29.8-41.5-49.3-73.8-49.3z"
p-id="7995"
fill="#d81e06"
></path>
<path
d="M513.9 524.6c-19.1 0-37.5-8.1-50.4-22.2l-97.7-106.7c-10.2-11.1-9.4-28.4 1.7-38.5 11.1-10.2 28.4-9.4 38.5 1.7l97.7 106.7c3.6 3.9 7.9 4.5 10.2 4.5 2.3 0 6.6-0.6 10.2-4.5l95.5-104.2c10.2-11.1 27.4-11.9 38.5-1.7 11.1 10.2 11.9 27.4 1.7 38.5l-95.5 104.2c-13 14.1-31.3 22.2-50.4 22.2z"
p-id="7996"
fill="#d81e06"
></path>
</svg>
</div>
<div class="block">
<h3>{{ item.title }}</h3>
<p class="tips">{{ item.description }}</p>
<p v-if="item.tip" class="tips">{{ item.tip }}</p>
</div>
</li>
</ul>
<!-- 弹窗组件 -->
<custom-split-dialog class="active" ref="customTable">
</custom-split-dialog>
<!-- 添加题词预览组件 -->
<extract-preview
@update:visible="value => (previewVisible = value)"
style="z-index: 2010"
:visible.sync="previewVisible"
:extract-results="extractResults"
:is-auto-extract="activeIndex === 0"
:loading="previewLoading"
:documentList="documentList"
@confirm="handlePreviewConfirm"
/>
</div>
<div class="card-bottom text-right mt10">
<el-button type="primary" size="medium" @click="onBack()">
取消
</el-button>
<el-button
type="primary"
size="medium"
@click="nextStep(documentExtractId)"
>
确定
</el-button>
</div>
</div>
</div>
</template>
<script>
import CustomSplitDialog from './CustomWords.vue'
import ExtractPreview from './ExtractPreview.vue'
import {
datasetDocumentEx,
execExtract,
getExtractResultList,
saveContentToDocument
} from '@/api/generatedApi'
export default {
name: 'splitConfig',
components: {
CustomSplitDialog,
ExtractPreview
},
data() {
return {
dialogVisible: false,
activeIndex: 0,
previewVisible: false,
extractResults: [],
previewLoading: false,
splitOptions: [
{
icon: 'el-icon-setting',
title: '立即挖掘',
description:
'使用系统默认的题词方式,适合新手或紧急任务,直接使用系统预设题词规则处理文本。',
tip: '提示:首次使用时建议先用自动题词测试效果,再决定是否调整。'
},
{
icon: 'el-icon-medal',
title: '自定义规则',
description:
'使用自定义题词方式可以根据具体需求灵活调整文本分割逻辑。',
tip: '但需要权衡灵活性与复杂度,需要用户具备一定的题词经验。'
}
],
isRedig: false,
// 题词结果
digRes: [],
documentId: '',
extractStatus: {
timer: NaN,
status: undefined
}
}
},
props: {
documentList: {
type: Array,
default: () => []
},
documentExtractId: {
type: String,
default: () => ''
}
},
watch: {},
filters: {},
methods: {
handleClick(index) {
this.activeIndex = index
if (index === 1) {
this.$refs.customTable.init()
} else {
this.$refs.customTable.close()
}
},
// 构建执行题词的参数
buildExecExtractParams(documentId) {
let params = {
documentId: documentId,
beAuto: this.activeIndex === 0
}
let splitDocIds = documentId.split(',')
if (splitDocIds.length > 1) {
params.documentId = undefined
params.documentIds = splitDocIds
}
if (!params.beAuto && this.$refs.customTable.ruleId) {
params.rulesId = this.$refs.customTable.ruleId
}
return params
},
// 执行题词操作
async execExtractOperation(params) {
if (!params.beAuto && !params.rulesId) {
this.$message.error('请勾选数据')
return false
}
const res = await execExtract(params)
if (res.content.result !== '0') {
throw new Error(res.content.resultMessage || '执行题词失败')
}
return res.content.content
},
// 显示预览
showExtractPreview(results) {
this.extractResults = results || []
this.previewVisible = true
},
// 获取题词结果列表 - 修改后的方法
async getExtractResultOperation() {
const params = { documentId: this.documentId }
const res = await getExtractResultList(params)
if (res.content.result !== '0') {
throw new Error(res.content.resultMessage || '获取题词结果失败')
}
// this.digRes = res.content.content || []
const results = res.content.content || []
// 显示预览弹窗
this.showExtractPreview(results)
},
// 处理预览确认
handlePreviewConfirm(extractResults) {
this.$router.push({
path: '/knowledge/reviewKnowledge',
query: {
documentId: this.documentId,
datasetId: this.$route.query.datasetId,
active: '3'
}
})
// this.saveContentToDocumentOperation(this.documentId, extractResults)
},
// 保存题词内容到文档
async saveContentToDocumentOperation(documentId, resultList) {
const params = {
documentId,
resultDTOList: resultList.map(item => ({
id: item.id,
attribute: item.attribute,
attributeContent: item.attributeContent
}))
}
await saveContentToDocument(params)
this.$router.push({
path: '/knowledge/detail',
query: { ...this.$route.query }
})
},
// 主方法
async nextStep() {
this.documentId = this.$route.query.documentId
const params = this.buildExecExtractParams(this.documentId)
this.execExtractOperation(params).then(async res => {
if (res) {
this.getExtractStatus()
}
})
// return new Promise(async (resolve, reject) => {
// try {
// // 1. 执行题词
// const params = this.buildExecExtractParams(this.documentId)
// this.execExtractOperation(params).then(async res => {
// if (res) {
// await this.getExtractResultOperation(this.documentId)
// // 显示预览弹窗
// // this.showExtractPreview(res)
// }
// })
// } catch (error) {
// console.error('题词操作失败:', error)
// reject({
// success: false,
// message: error.message || '题词操作失败'
// })
// }
// })
},
getExtractStatus() {
if (this.extractStatus.timer) return
this.$notify({
title: '提示',
message: this.$createElement('i', {}, this.extractStatusResults)
})
datasetDocumentEx({ documentId: this.documentId })
.then(() => {
this.onBack()
})
},
onBack() {
this.$router.history.go(-1)
}
},
computed: {
columns: vm => {
return [
{
prop: 'attribute',
label: '属性',
width: 90
},
{
prop: 'attributeContent',
label: '题词内容',
render: (h, p) => {
return h('el-input', {
props: {
value: p.row.attributeContent,
size: 'medium',
disabled: !vm.isEdit
},
on: {
input: value => {
p.row.attributeContent = value
}
}
})
}
}
]
},
extractStatusResults() {
const map = new Map([
[0, '相关数据信息还未执行'],
[1, '相关数据已经处理完成,请移步相关知识库查看'],
[2, '数据处理失败,请返回相关知识库重新处理相应内容'],
[3, '题词数据挖掘正在排队中,稍后将进行处理'],
[4, '题词数据挖掘正在处理中']
])
if (map.has(this.extractStatus.status))
return map.get(this.extractStatus.status)
return '数据正在处理中'
}
}
}
</script>
<style scoped lang="scss">
@import '@/assets/sass/renderSass/theme.scss';
.splitConfig {
.title {
font-size: 20px;
margin: 10px 0;
font-weight: bold;
}
ul {
list-style-type: none;
padding: 10px;
& li {
flex: 1;
border: 1px solid #d9d9d9;
padding: 15px;
border-radius: 6px;
list-style-type: none;
//width: 80%;
p {
margin: 10px 0;
font-size: 14px;
color: #666;
}
.block {
margin-left: 20px;
h3 {
margin-bottom: 20px;
font-size: 16px;
color: #333;
}
.tips {
color: #9e9e9e;
}
}
&.active {
border: 1px solid var(--color-primary);
//background: #fefefe;
transition: all 1s ease;
//color: #fff;
& .tips {
//color: #fff;
//transition: all 1s ease;
}
}
}
li + li {
margin-left: 20px;
}
}
}
</style>

View File

@@ -29,7 +29,7 @@
<div class="icon-text" v-else>2</div>
</template>
</el-step>
<el-step title="题词拆分配置">
<el-step title="直接上传至知识库">
<template slot="icon">
<div class="icon-text" v-if="active === 2">STEP3</div>
<div class="icon-text" v-else>3</div>
@@ -64,15 +64,22 @@
@handleReUpload="handleReUpload"
:documentId="documentId"
></step-split-config>
<step-words
ref="words"
<!-- <step-words-->
<!-- ref="words"-->
<!-- v-if="active === 2"-->
<!-- :documentList="this.documentList"-->
<!-- ></step-words>-->
<review-knowledge
:documentId="documentId"
ref="reviewKnowledge"
v-if="active === 2"
:documentList="this.documentList"
></step-words>
>
</review-knowledge>
</transition>
</div>
</div>
<div class="card-bottom text-right">
<div class="card-bottom text-right" v-if="active < 2">
<el-button size="medium" @click="$router.history.go(-1)">取消</el-button>
<el-button size="medium" @click="active--" v-if="active > 1"
>上一步</el-button
@@ -127,6 +134,8 @@ import SplitConfig from '@/views/knowledge/detail/components/split/Index.vue'
import Words from '@/views/knowledge/detail/components/words/Index.vue'
import magic from '@/assets/images/konwledge/magic.png'
import { datasetDocumentEx, directEmbedding } from '@/api/generatedApi'
import ReviewKnowledge from '@/views/knowledge/detail/reviewKnowledge.vue'
import router from '@/router'
// import StepC
export default {
name: 'create',
@@ -143,6 +152,7 @@ export default {
props: {},
watch: {},
components: {
ReviewKnowledge,
StepSplitConfig: SplitConfig,
StepPreprocessing,
StepWords: Words
@@ -219,17 +229,28 @@ export default {
},
async nextStep() {
this.updateRouteParams()
if (this.active === 0) {
this.$refs.stepPreProcessing.uploadFiled()
} else if (this.active === 1) {
await this.$refs.splitConfig.nextStep(this.documentId)
} else if (this.active === 2) {
await this.$refs.words.nextStep(this.documentId)
// await this.$refs.words.nextStep(this.documentId)
}
},
updateRouteParams() {
this.$router.replace({
query: {
...this.$route.query, // 保留当前所有查询参数
documentId: this.documentId, // 修改你需要的参数
active: this.active
}
})
},
// 预览完成
handlePreviewConfirm() {
this.active = 2
this.updateRouteParams()
},
// 重新上传
handleReUpload() {
@@ -253,6 +274,7 @@ export default {
this.documentId = documentId
await this.getDocumentId(documentId)
}
// TODO case 2 控制台报错 Cannot read properties of undefined (reading 'getExtractResultOperation'
if (activeLevel !== undefined) {
this.active = Number(activeLevel)
switch (this.active) {

View File

@@ -21,8 +21,8 @@
size="small"
v-else
v-model="copyKnowledgeName"
>{{ knowledgeName }}</el-input
>
>{{ knowledgeName }}
</el-input>
<el-icon
class="fs16 el-icon-edit-outline cursor-pointer"
@click.native="editKnowledgeName"
@@ -30,11 +30,11 @@
/>
<div v-else>
<el-button type="primary" size="medium" @click="saveKnowledgeName"
>保存</el-button
>
>保存
</el-button>
<el-button size="medium" @click="cancelKnowledgeName"
>取消</el-button
>
>取消
</el-button>
</div>
<span class="segment-content">{{
segmentedMode | filterSegmentedMode
@@ -123,8 +123,8 @@
size="medium"
class="fs14"
@click="jumpAddKnowledge"
>立即添加</el-button
>
>立即添加
</el-button>
</div>
</el-empty>
@@ -188,8 +188,8 @@
</el-form>
<div class="mt15 flex align-items-c justify-content-b">
<el-button size="medium" type="primary" @click="search"
>查询</el-button
>
>查询
</el-button>
<el-button size="medium" @click="reset">重置</el-button>
</div>
</div>
@@ -279,6 +279,21 @@
</el-drawer>
<!--检索设置弹窗-->
<search-setting ref="searchSetting"></search-setting>
<!--知识挖掘抽屉-->
<el-drawer
:title="knowledgeMiningDrawer.title"
v-if="knowledgeMiningDrawer.visible"
:visible.sync="knowledgeMiningDrawer.visible"
size="45%"
:wrapperClosable="false"
>
<words
ref="words"
@openMetaDrawer="handleMetaData"
@close="close"
:document-extract-id="documentExtractId"
></words>
</el-drawer>
</div>
</template>
<script>
@@ -290,6 +305,8 @@ import {
datasetUpdate,
downloadOriginalFile,
getDatasetById,
getExtractResultList,
getUnfinishedExtract,
relatedApps
} from '@/api/generatedApi'
import { getUserList } from '@/api/generatedApi/system'
@@ -310,6 +327,8 @@ import {
getDirectoryTree,
markedMetadata
} from '@/api/directory'
import Words from '@/views/knowledge/detail/components/words/Index.vue'
export default {
name: 'index',
// 父子组件共享
@@ -335,6 +354,10 @@ export default {
title: '标注元数据',
visible: false
},
knowledgeMiningDrawer: {
title: '知识挖掘',
visible: false
},
activeName: -1,
drawer: false,
drawerForm: false,
@@ -370,7 +393,8 @@ export default {
treeData: [],
dialogVisible: false,
currentParentId: '',
currentDirectoryId: ''
currentDirectoryId: '',
documentExtractId: ''
}
},
props: {},
@@ -382,7 +406,8 @@ export default {
hitTest,
knowledgeForm,
DocumentDrawer,
MetadataOperator
MetadataOperator,
Words
},
methods: {
getUserData() {
@@ -558,6 +583,28 @@ export default {
}
})
},
// 知识挖掘操作
async handleKnowledgeMining(row) {
// this.previewLoading = true
const params = { documentId: row.id }
const res = await getExtractResultList(params)
if (res.content.result !== '0') {
throw new Error(res.content.resultMessage || '获取题词结果失败')
}
const isVisible = !!res.content.content.length
if (isVisible) {
this.knowledgeMiningDrawer.visible = isVisible
} else {
this.$router.push({
name: 'custom-word',
query: {
...this.$route.query,
documentId: row.id
}
})
}
this.documentExtractId = row.id
},
// 获取文档详细信息(包含分词规则和词频规则)
getDocumentExInfo(documentId) {
datasetDocumentEx({ documentId })
@@ -650,8 +697,7 @@ export default {
if (Array.isArray(node.documents) && node.documents.length > 0) {
const docChildren = node.documents.map(doc => ({
...doc,
id: doc.id,
knowledgeName: doc.knowledgeName,
name: doc.knowledgeName,
type: 'document',
children: []
}))
@@ -665,11 +711,27 @@ export default {
})
}
},
// 为树形数据添加层级信息
addLevelToTree(nodes, level = 0) {
if (!Array.isArray(nodes)) return
nodes.forEach(node => {
// 为当前节点添加层级
node.level = level
// 如果有子节点,递归处理
if (Array.isArray(node.children) && node.children.length > 0) {
this.addLevelToTree(node.children, level + 1)
}
})
},
async loadTree() {
getDirectoryTree({ datasetId: this.$route.query.datasetId }).then(
response => {
const data = response.content.content
data.forEach(node => this.mergeDocumentsToChildren(node))
// 为树形数据添加层级信息
this.addLevelToTree(data)
this.treeData = data
}
)
@@ -721,23 +783,54 @@ export default {
'是否确认删除' + row.name + '目录?',
'warning'
)
},
// 获取正在执行的知识挖掘文档
getExtractingData() {
let { datasetId } = this.$route.query
// 判断是否已经在轮询中,防止重复启动定时器
if (this.pollingTimer) return
// 开始轮询
let documentIds = []
this.pollingTimer = setInterval(async () => {
try {
const res = await getUnfinishedExtract(datasetId)
if (res.content.result === '0' && res.content.content.length > 0) {
documentIds = res.content.content
// 禁用知识挖掘按钮
documentIds.map(docId => {
let filterItem = this.list.find(item => {
return item.id === docId
})
if (filterItem) {
if (filterItem.extractStatus < 2) {
filterItem.extractStatus = 4
}
}
})
} else {
// 清除定时器
clearInterval(this.pollingTimer)
this.pollingTimer = null
// 启用知识挖掘按钮
documentIds.map(docId => {
let filterItem = this.list.find(item => {
return item.id === docId
})
if (filterItem) {
if (filterItem.extractStatus > 2) {
filterItem.extractStatus = 1
}
}
})
}
} catch (error) {
clearInterval(this.pollingTimer)
this.pollingTimer = null
}
}, 3000)
}
// /**
// * 跳转到上传知识页面
// * @param directory 目录节点对象,可选
// */
// jumpAddKnowledge(directory) {
// sessionStorage.removeItem('documentId')
// let { datasetId } = this.$route.query
// // 可根据需要将目录id传递给上传页面
// this.$router.push({
// path: '/knowledge/detail/create',
// query: {
// datasetId: datasetId,
// directoryId: directory ? directory.id : undefined
// }
// })
// }
},
filters: {
filterSegmentedMode(val) {
@@ -757,7 +850,6 @@ export default {
return item ? item.label : '否'
}
},
created() {},
async mounted() {
this.getKnowledgeDetail()
// 获取知识库文件列表
@@ -778,6 +870,7 @@ export default {
// this.viewDocumentDetail(row[0])
// sessionStorage.removeItem('documentId')
// }, 1000)
this.getExtractingData()
},
computed: {
datasetId() {
@@ -948,6 +1041,24 @@ export default {
}
// '标注元数据'
),
h(
'el-button',
{
class: 'floatSpan',
props: {
type: 'primary',
size: 'mini',
icon: 'el-icon-cpu',
title: '知识挖掘',
disabled:
params.row.optStatus < 2 || params.row.extractStatus > 2
},
on: {
click: () => this.handleKnowledgeMining(params.row)
}
}
// '知识挖掘'
),
params.row.optStatus < 4
? h(
'el-button',
@@ -975,12 +1086,27 @@ export default {
return [
{
prop: 'name',
key: '名称'
// render: (h, params) => params.row.type === 'directory' ? params.row.name : ''
},
{
key: '知识文件名称',
prop: 'knowledgeName'
key: '名称',
render: (h, params) => {
if (params.row.type === 'directory') {
// 如果是目录类型,直接渲染目录名称
return h('div', params.row.name)
} else if (params.row.type === 'document') {
// 如果是文档类型根据层级计算margin-left
const level = params.row.level || 0
const marginLeft = (level + 1) * 10
return h(
'div',
{
style: {
marginLeft: marginLeft + 'px'
}
},
params.row.name
)
}
return h('div', params.row.name)
}
},
{
key: '知识文件来源',
@@ -1150,6 +1276,27 @@ export default {
// '标注元数据'
)
: '',
params.row.type === 'document'
? h(
'el-button',
{
class: 'floatSpan',
props: {
type: 'primary',
size: 'mini',
icon: 'el-icon-cpu',
title: '知识挖掘',
disabled:
params.row.optStatus < 2 ||
params.row.extractStatus > 2
},
on: {
click: () => this.handleKnowledgeMining(params.row)
}
}
// '知识挖掘'
)
: '',
params.row.type === 'document'
? h(
'el-button',
@@ -1459,6 +1606,7 @@ export default {
.hover-back {
padding: 10px 5px;
&:hover {
background: rgba(87, 104, 161, 0.2);
border-radius: 5px;

View File

@@ -236,7 +236,9 @@ import {
segmentEstimate,
preprocessSegmentEstimate,
splitSegmentEstimate,
extractSegmentEstimate
extractSegmentEstimate,
splitAndExtractEmbedding,
splitAndExtractSegmentEstimate
} from '@/api/generatedApi/embedding'
import MarkdownIt from 'markdown-it'
@@ -300,7 +302,8 @@ export default {
let splitDocIds = documentId.split(',')
let api = segmentEstimate
switch (active) {
console.log(active)
switch (String(active)) {
case '0':
api = segmentEstimate
break
@@ -313,6 +316,9 @@ export default {
case '3':
api = extractSegmentEstimate
break
case '4':
api = splitAndExtractSegmentEstimate
break
}
api({
documentId: splitDocIds[this.activeIndex],
@@ -356,7 +362,8 @@ export default {
let splitDocIds = documentId.split(',')
let api = directEmbedding
switch (active) {
switch (String(active)) {
case '0':
api = directEmbedding
break
@@ -369,6 +376,9 @@ export default {
case '3':
api = extractEmbedding
break
case '4':
api = splitAndExtractEmbedding
break
}
let params = {