|
@@ -187,7 +187,7 @@
|
|
|
</div> -->
|
|
</div> -->
|
|
|
</div>
|
|
</div>
|
|
|
<div class="knowledge-actions" @click.stop>
|
|
<div class="knowledge-actions" @click.stop>
|
|
|
- <button class="btn btn-secondary btn-sm" @click="editKnowledge(item)">
|
|
|
|
|
|
|
+ <button class="btn btn-secondary btn-sm" @click="editDocument(item)">
|
|
|
<i class="fas fa-edit"></i>
|
|
<i class="fas fa-edit"></i>
|
|
|
</button>
|
|
</button>
|
|
|
<el-popconfirm title="确认删除?" @confirm="deleteKnowledge(item)">
|
|
<el-popconfirm title="确认删除?" @confirm="deleteKnowledge(item)">
|
|
@@ -401,27 +401,34 @@
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<!-- 添加知识弹窗 -->
|
|
<!-- 添加知识弹窗 -->
|
|
|
- <div v-if="showAddModal" class="modal-overlay" @click.self="showAddModal = false">
|
|
|
|
|
|
|
+ <div v-if="showAddModal" class="modal-overlay" style="z-index: 1002;" @click.self="showAddModal = false">
|
|
|
<div class="modal add-modal">
|
|
<div class="modal add-modal">
|
|
|
<div class="modal-header">
|
|
<div class="modal-header">
|
|
|
- <div class="modal-title"><i class="fas fa-plus"></i> 添加知识</div>
|
|
|
|
|
|
|
+ <div class="modal-title"><i class="fas fa-plus"></i> {{chunkType=='add'?'添加':'编辑'}}知识</div>
|
|
|
<button class="modal-close" @click="showAddModal = false"><i class="fas fa-times"></i></button>
|
|
<button class="modal-close" @click="showAddModal = false"><i class="fas fa-times"></i></button>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="modal-body">
|
|
<div class="modal-body">
|
|
|
<div class="form-group">
|
|
<div class="form-group">
|
|
|
<label class="form-label">问题/关键词 <span class="required">*</span></label>
|
|
<label class="form-label">问题/关键词 <span class="required">*</span></label>
|
|
|
- <input type="text" class="form-input" v-model="newKnowledge.name" placeholder="例如:MOQ最小起订量是多少?">
|
|
|
|
|
|
|
+ <input type="text" class="form-input" v-model="newKnowledge.content" placeholder="例如:MOQ最小起订量是多少?">
|
|
|
</div>
|
|
</div>
|
|
|
<div class="form-group">
|
|
<div class="form-group">
|
|
|
<label class="form-label">答案/内容 <span class="required">*</span></label>
|
|
<label class="form-label">答案/内容 <span class="required">*</span></label>
|
|
|
- <textarea class="form-textarea" v-model="newKnowledge.text" rows="4" placeholder="输入详细答案..."></textarea>
|
|
|
|
|
|
|
+ <textarea class="form-textarea" v-model="newKnowledge.answer" rows="4" placeholder="输入详细答案..."></textarea>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="form-group">
|
|
<div class="form-group">
|
|
|
<label class="form-label">知识分类 <span class="required">*</span></label>
|
|
<label class="form-label">知识分类 <span class="required">*</span></label>
|
|
|
- <select class="form-select" v-model="newKnowledge.dataset_id">
|
|
|
|
|
|
|
+ <select class="form-select" v-model="newKnowledge.dataset_id" @change='getDocument' :disabled='chunkType=="edit"'>
|
|
|
<option value="">选择分类</option>
|
|
<option value="">选择分类</option>
|
|
|
<option v-for="cat in categories" :key="cat.id" :value="cat.id">{{ cat.name }}</option>
|
|
<option v-for="cat in categories" :key="cat.id" :value="cat.id">{{ cat.name }}</option>
|
|
|
</select>
|
|
</select>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="form-group">
|
|
|
|
|
+ <label class="form-label">知识文档 <span class="required">*</span></label>
|
|
|
|
|
+ <select class="form-select" v-model="newKnowledge.document_id" :disabled='chunkType=="edit"'>
|
|
|
|
|
+ <option value="">选择文档</option>
|
|
|
|
|
+ <option v-for="cat in documentList" :key="cat.id" :value="cat.id">{{ cat.name }}</option>
|
|
|
|
|
+ </select>
|
|
|
</div>
|
|
</div>
|
|
|
<!-- <div class="form-group">
|
|
<!-- <div class="form-group">
|
|
|
<label class="form-label">关键词标签</label>
|
|
<label class="form-label">关键词标签</label>
|
|
@@ -434,7 +441,7 @@
|
|
|
</div>
|
|
</div>
|
|
|
<div class="modal-footer">
|
|
<div class="modal-footer">
|
|
|
<button class="btn btn-secondary" @click="showAddModal = false">取消</button>
|
|
<button class="btn btn-secondary" @click="showAddModal = false">取消</button>
|
|
|
- <button class="btn btn-primary" @click="addKnowledge"><i class="fas fa-plus"></i> 添加</button>
|
|
|
|
|
|
|
+ <button class="btn btn-primary" @click="addKnowledge"><i class="fas fa-plus"></i> {{chunkType=='add'?'添加':'确认'}}</button>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
@@ -497,15 +504,15 @@
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
- <!-- Knowledge Detail Modal -->
|
|
|
|
|
|
|
+ <!-- 知识块详情弹窗 -->
|
|
|
<div v-if="showDetailModal && selectedKnowledge" class="modal-overlay" @click.self="showDetailModal = false">
|
|
<div v-if="showDetailModal && selectedKnowledge" class="modal-overlay" @click.self="showDetailModal = false">
|
|
|
<div class="modal detail-modal">
|
|
<div class="modal detail-modal">
|
|
|
<div class="modal-header">
|
|
<div class="modal-header">
|
|
|
<div class="modal-title">
|
|
<div class="modal-title">
|
|
|
- <span class="detail-icon" :style="{ background: selectedKnowledge.iconBg }">{{ selectedKnowledge.icon }}</span>
|
|
|
|
|
|
|
+ <!-- <span class="detail-icon" :style="{ background: selectedKnowledge.iconBg }">{{ selectedKnowledge.icon }}</span> -->
|
|
|
<div>
|
|
<div>
|
|
|
- <h3>{{ selectedKnowledge.question }}</h3>
|
|
|
|
|
- <p>{{ selectedKnowledge.categoryName }}</p>
|
|
|
|
|
|
|
+ <h3>{{ selectedKnowledge.sign_content }}</h3>
|
|
|
|
|
+ <!-- <p>{{ selectedKnowledge.categoryName }}</p> -->
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
<button class="modal-close" @click="showDetailModal = false"><i class="fas fa-times"></i></button>
|
|
<button class="modal-close" @click="showDetailModal = false"><i class="fas fa-times"></i></button>
|
|
@@ -515,22 +522,22 @@
|
|
|
<div class="detail-label"><i class="fas fa-lightbulb"></i> 答案内容</div>
|
|
<div class="detail-label"><i class="fas fa-lightbulb"></i> 答案内容</div>
|
|
|
<div class="detail-content">{{ selectedKnowledge.answer }}</div>
|
|
<div class="detail-content">{{ selectedKnowledge.answer }}</div>
|
|
|
</div>
|
|
</div>
|
|
|
- <div class="detail-section" v-if="selectedKnowledge.extendedAnswer">
|
|
|
|
|
|
|
+ <!-- <div class="detail-section" v-if="selectedKnowledge.extendedAnswer">
|
|
|
<div class="detail-label"><i class="fas fa-file-alt"></i> 扩展说明</div>
|
|
<div class="detail-label"><i class="fas fa-file-alt"></i> 扩展说明</div>
|
|
|
<div class="detail-content extended">{{ selectedKnowledge.extendedAnswer }}</div>
|
|
<div class="detail-content extended">{{ selectedKnowledge.extendedAnswer }}</div>
|
|
|
- </div>
|
|
|
|
|
- <div class="detail-section">
|
|
|
|
|
|
|
+ </div> -->
|
|
|
|
|
+ <!-- <div class="detail-section">
|
|
|
<div class="detail-label"><i class="fas fa-tags"></i> 关键词标签</div>
|
|
<div class="detail-label"><i class="fas fa-tags"></i> 关键词标签</div>
|
|
|
<div class="detail-tags">
|
|
<div class="detail-tags">
|
|
|
<span v-for="tag in selectedKnowledge.tags" :key="tag" class="tag">{{ tag }}</span>
|
|
<span v-for="tag in selectedKnowledge.tags" :key="tag" class="tag">{{ tag }}</span>
|
|
|
</div>
|
|
</div>
|
|
|
- </div>
|
|
|
|
|
- <div class="detail-section" v-if="selectedKnowledge.relatedQuestions && selectedKnowledge.relatedQuestions.length">
|
|
|
|
|
|
|
+ </div> -->
|
|
|
|
|
+ <!-- <div class="detail-section" v-if="selectedKnowledge.relatedQuestions && selectedKnowledge.relatedQuestions.length">
|
|
|
<div class="detail-label"><i class="fas fa-link"></i> 相关问题</div>
|
|
<div class="detail-label"><i class="fas fa-link"></i> 相关问题</div>
|
|
|
<div class="related-questions">
|
|
<div class="related-questions">
|
|
|
<div v-for="(q, idx) in selectedKnowledge.relatedQuestions" :key="idx" class="related-item">{{ q }}</div>
|
|
<div v-for="(q, idx) in selectedKnowledge.relatedQuestions" :key="idx" class="related-item">{{ q }}</div>
|
|
|
</div>
|
|
</div>
|
|
|
- </div>
|
|
|
|
|
|
|
+ </div> -->
|
|
|
<div class="detail-stats-row">
|
|
<div class="detail-stats-row">
|
|
|
<div class="detail-stat">
|
|
<div class="detail-stat">
|
|
|
<i class="fas fa-eye"></i>
|
|
<i class="fas fa-eye"></i>
|
|
@@ -660,7 +667,7 @@
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
import { ref, computed } from 'vue'
|
|
import { ref, computed } from 'vue'
|
|
|
-import { knowledgeDatasets,knowledgeDocuments,createKnowledge,chatMessages,baseTraining,creatTraining,baseStatistics,getAllChunks,getAllDocumnets,delDocuments,delChunk } from '../api/knowledge'
|
|
|
|
|
|
|
+import { knowledgeDatasets,knowledgeDocuments,createKnowledge,createChunk,editChunk,chatMessages,baseTraining,creatTraining,baseStatistics,getAllChunks,getAllDocumnets,delDocuments,delChunk } from '../api/knowledge'
|
|
|
import { formatTimeAgo } from '@/utils/time'
|
|
import { formatTimeAgo } from '@/utils/time'
|
|
|
import { ElMessage } from 'element-plus'
|
|
import { ElMessage } from 'element-plus'
|
|
|
|
|
|
|
@@ -680,6 +687,7 @@ const confidenceThreshold = ref(70)
|
|
|
const showToast = ref(false)
|
|
const showToast = ref(false)
|
|
|
const toastMessage = ref('')
|
|
const toastMessage = ref('')
|
|
|
const toastType = ref('success')
|
|
const toastType = ref('success')
|
|
|
|
|
+const chunkType = ref('add')
|
|
|
|
|
|
|
|
|
|
|
|
|
const syncStatus = {
|
|
const syncStatus = {
|
|
@@ -699,11 +707,9 @@ const tabs = ref([
|
|
|
|
|
|
|
|
const newKnowledge = ref({
|
|
const newKnowledge = ref({
|
|
|
dataset_id: '',
|
|
dataset_id: '',
|
|
|
- text: '',
|
|
|
|
|
- name: '',
|
|
|
|
|
- indexing_technique: "high_quality",
|
|
|
|
|
- doc_form: "qa_model",
|
|
|
|
|
- doc_language:"Chinese Simplified"
|
|
|
|
|
|
|
+ document_id: '',
|
|
|
|
|
+ content: '',
|
|
|
|
|
+ answer: '',
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// const categories = ref([
|
|
// const categories = ref([
|
|
@@ -812,6 +818,7 @@ const changeCategory = () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const knowledgeList = ref([])
|
|
const knowledgeList = ref([])
|
|
|
|
|
+const documentList = ref([])
|
|
|
// 获取知识列表
|
|
// 获取知识列表
|
|
|
const categoryId = ref()
|
|
const categoryId = ref()
|
|
|
const categoryTotal = ref()
|
|
const categoryTotal = ref()
|
|
@@ -826,14 +833,23 @@ const openCategory = (category) => {
|
|
|
showToastMessage(`正在加载 ${category.name} 分类...`, 'success')
|
|
showToastMessage(`正在加载 ${category.name} 分类...`, 'success')
|
|
|
getCategoryList(category.id)
|
|
getCategoryList(category.id)
|
|
|
}
|
|
}
|
|
|
-const getCategoryList = (id) => {
|
|
|
|
|
- categoryId.value = id?id:''
|
|
|
|
|
- documentsParams.value.dataset_id = id?id:''
|
|
|
|
|
- documentsParams.value.keyword = searchQuery.value
|
|
|
|
|
|
|
+const getCategoryList = (id,type) => {
|
|
|
|
|
+ if(!type){
|
|
|
|
|
+ categoryId.value = id?id:''
|
|
|
|
|
+ documentsParams.value.dataset_id = id?id:''
|
|
|
|
|
+ documentsParams.value.keyword = searchQuery.value
|
|
|
|
|
+ documentsParams.value.pageSize = 10
|
|
|
|
|
+ }else{
|
|
|
|
|
+ documentsParams.value.pageSize = 9999
|
|
|
|
|
+ }
|
|
|
getAllDocumnets(documentsParams.value).then(res => {
|
|
getAllDocumnets(documentsParams.value).then(res => {
|
|
|
console.log(res)
|
|
console.log(res)
|
|
|
- knowledgeList.value = res.result.data
|
|
|
|
|
- tabs.value[1].count = categoryTotal.value = res.result.total
|
|
|
|
|
|
|
+ if(type=='add'){ //添加知识获取分类
|
|
|
|
|
+ documentList.value = res.result.data
|
|
|
|
|
+ }else{
|
|
|
|
|
+ knowledgeList.value = res.result.data
|
|
|
|
|
+ tabs.value[1].count = categoryTotal.value = res.result.total
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
getCategoryList()
|
|
getCategoryList()
|
|
@@ -1052,29 +1068,51 @@ const formatNumber = (num) => num.toLocaleString()
|
|
|
|
|
|
|
|
|
|
|
|
|
const editKnowledge = (item) => {
|
|
const editKnowledge = (item) => {
|
|
|
- showDetailModal.value = false
|
|
|
|
|
- showToastMessage('正在编辑知识...', 'success')
|
|
|
|
|
|
|
+ chunkType.value = 'edit'
|
|
|
|
|
+ newKnowledge.value.content = item.content
|
|
|
|
|
+ newKnowledge.value.answer=item.answer
|
|
|
|
|
+ newKnowledge.value.dataset_id=item.dataset_id
|
|
|
|
|
+ newKnowledge.value.segment_id=item.id
|
|
|
|
|
+ getCategoryList(item.dataset_id,'add')
|
|
|
|
|
+ newKnowledge.value.document_id=item.document_id
|
|
|
|
|
+ showAddModal.value = true
|
|
|
}
|
|
}
|
|
|
|
|
+const editDocument = (item) => {}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+const getDocument = () =>{
|
|
|
|
|
+ getCategoryList(newKnowledge.value.dataset_id,'add')
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
const addKnowledgeDocument = ()=> {
|
|
const addKnowledgeDocument = ()=> {
|
|
|
- newKnowledge.value.name = ''
|
|
|
|
|
- newKnowledge.value.text=''
|
|
|
|
|
|
|
+ newKnowledge.value.content = ''
|
|
|
|
|
+ newKnowledge.value.answer=''
|
|
|
newKnowledge.value.dataset_id=''
|
|
newKnowledge.value.dataset_id=''
|
|
|
|
|
+ newKnowledge.value.document_id=''
|
|
|
|
|
+ newKnowledge.value.segment_id=''
|
|
|
|
|
+ chunkType.value = 'add'
|
|
|
showAddModal.value = true
|
|
showAddModal.value = true
|
|
|
}
|
|
}
|
|
|
const addKnowledge = () => {
|
|
const addKnowledge = () => {
|
|
|
- if(!newKnowledge.value.name||!newKnowledge.value.text||!newKnowledge.value.dataset_id){
|
|
|
|
|
|
|
+ if(!newKnowledge.value.answer||!newKnowledge.value.content||!newKnowledge.value.dataset_id||!newKnowledge.value.document_id){
|
|
|
ElMessage.error('请填入必填项')
|
|
ElMessage.error('请填入必填项')
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
- createKnowledge(newKnowledge.value).then(res => {
|
|
|
|
|
- if(res.success){
|
|
|
|
|
- howToastMessage('知识添加成功,AI 已学习', 'success')
|
|
|
|
|
- showAddModal.value = false
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ if(chunkType.value =='add'){
|
|
|
|
|
+ createChunk(newKnowledge.value).then(res => {
|
|
|
|
|
+ if(res.success){
|
|
|
|
|
+ howToastMessage('知识添加成功,AI 已学习', 'success')
|
|
|
|
|
+ showAddModal.value = false
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }else{
|
|
|
|
|
+ editChunk(newKnowledge.value).then(res => {
|
|
|
|
|
+ if(res.success){
|
|
|
|
|
+ howToastMessage('知识编辑成功,AI 已学习', 'success')
|
|
|
|
|
+ showAddModal.value = false
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const optimizeAnswer = (item) => {
|
|
const optimizeAnswer = (item) => {
|