feat: 问题修复
This commit is contained in:
parent
4b3497ac58
commit
78fa4af45a
@ -1,48 +1,56 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog title="知识库引用" v-model="dialogVisible" destroy-on-close>
|
<el-dialog
|
||||||
|
class="paragraph-source"
|
||||||
|
title="知识库引用"
|
||||||
|
v-model="dialogVisible"
|
||||||
|
destroy-on-close
|
||||||
|
append-to-body
|
||||||
|
>
|
||||||
<el-scrollbar height="450">
|
<el-scrollbar height="450">
|
||||||
<el-form label-position="top">
|
<div class="p-16">
|
||||||
<el-form-item label="用户问题">
|
<el-form label-position="top">
|
||||||
<el-input v-model="detail.problem_text" disabled />
|
<el-form-item label="用户问题">
|
||||||
</el-form-item>
|
<el-input v-model="detail.problem_text" disabled />
|
||||||
<el-form-item label="优化后问题">
|
</el-form-item>
|
||||||
<el-input v-model="detail.padding_problem_text" disabled />
|
<el-form-item label="优化后问题">
|
||||||
</el-form-item>
|
<el-input v-model="detail.padding_problem_text" disabled />
|
||||||
<el-form-item label="引用分段">
|
</el-form-item>
|
||||||
<template v-for="(item, index) in detail.paragraph_list" :key="index">
|
<el-form-item label="引用分段">
|
||||||
<CardBox
|
<template v-for="(item, index) in detail.paragraph_list" :key="index">
|
||||||
shadow="hover"
|
<CardBox
|
||||||
:title="item.title || '-'"
|
shadow="hover"
|
||||||
:description="item.content"
|
:title="item.title || '-'"
|
||||||
class="paragraph-source-card cursor mb-8"
|
:description="item.content"
|
||||||
:class="item.is_active ? '' : 'disabled'"
|
class="paragraph-source-card cursor mb-8"
|
||||||
:showIcon="false"
|
:class="item.is_active ? '' : 'disabled'"
|
||||||
>
|
:showIcon="false"
|
||||||
<template #icon>
|
>
|
||||||
<AppAvatar :name="index + 1 + ''" class="mr-12 avatar-light" :size="22" />
|
<template #icon>
|
||||||
</template>
|
<AppAvatar :name="index + 1 + ''" class="mr-12 avatar-light" :size="22" />
|
||||||
<div class="active-button primary">{{ item.similarity?.toFixed(3) }}</div>
|
</template>
|
||||||
<template #footer>
|
<div class="active-button primary">{{ item.similarity?.toFixed(3) }}</div>
|
||||||
<div class="footer-content flex-between">
|
<template #footer>
|
||||||
<el-text>
|
<div class="footer-content flex-between">
|
||||||
<el-icon>
|
<el-text>
|
||||||
<Document />
|
<el-icon>
|
||||||
</el-icon>
|
<Document />
|
||||||
{{ item?.document_name }}
|
</el-icon>
|
||||||
</el-text>
|
{{ item?.document_name }}
|
||||||
<div class="flex align-center">
|
</el-text>
|
||||||
<AppAvatar class="mr-8" shape="square" :size="18">
|
<div class="flex align-center">
|
||||||
<img src="@/assets/icon_document.svg" style="width: 58%" alt="" />
|
<AppAvatar class="mr-8" shape="square" :size="18">
|
||||||
</AppAvatar>
|
<img src="@/assets/icon_document.svg" style="width: 58%" alt="" />
|
||||||
|
</AppAvatar>
|
||||||
|
|
||||||
<span class="ellipsis"> {{ item?.dataset_name }}</span>
|
<span class="ellipsis"> {{ item?.dataset_name }}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</template>
|
||||||
</template>
|
</CardBox>
|
||||||
</CardBox>
|
</template>
|
||||||
</template>
|
</el-form-item>
|
||||||
</el-form-item>
|
</el-form>
|
||||||
</el-form>
|
</div>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
@ -71,7 +79,12 @@ const open = (data: any, id?: string) => {
|
|||||||
|
|
||||||
defineExpose({ open })
|
defineExpose({ open })
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss">
|
||||||
|
.paragraph-source {
|
||||||
|
.el-dialog__body {
|
||||||
|
padding: 8px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
.paragraph-source-card {
|
.paragraph-source-card {
|
||||||
height: 210px;
|
height: 210px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -79,5 +92,10 @@ defineExpose({ open })
|
|||||||
-webkit-line-clamp: 5 !important;
|
-webkit-line-clamp: 5 !important;
|
||||||
height: 110px !important;
|
height: 110px !important;
|
||||||
}
|
}
|
||||||
|
.active-button {
|
||||||
|
position: absolute;
|
||||||
|
right: 16px;
|
||||||
|
top: 16px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -13,20 +13,20 @@
|
|||||||
<el-card shadow="always" class="dialog-card">
|
<el-card shadow="always" class="dialog-card">
|
||||||
<template v-for="(item, index) in prologueList" :key="index">
|
<template v-for="(item, index) in prologueList" :key="index">
|
||||||
<div
|
<div
|
||||||
v-if="isMdArray(item)"
|
v-if="item.type === 'question'"
|
||||||
@click="quickProblemHandel(item)"
|
@click="quickProblemHandel(item.str)"
|
||||||
class="problem-button ellipsis-2 mb-8"
|
class="problem-button ellipsis-2 mb-8"
|
||||||
:class="log ? 'disabled' : 'cursor'"
|
:class="log ? 'disabled' : 'cursor'"
|
||||||
>
|
>
|
||||||
<el-icon><EditPen /></el-icon>
|
<el-icon><EditPen /></el-icon>
|
||||||
{{ item }}
|
{{ item.str }}
|
||||||
</div>
|
</div>
|
||||||
<MdPreview
|
<MdPreview
|
||||||
v-else
|
v-else
|
||||||
class="mb-8"
|
class="mb-8"
|
||||||
ref="editorRef"
|
ref="editorRef"
|
||||||
editorId="preview-only"
|
editorId="preview-only"
|
||||||
:modelValue="item"
|
:modelValue="item.str"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</el-card>
|
</el-card>
|
||||||
@ -184,7 +184,7 @@ const props = defineProps({
|
|||||||
type: Object,
|
type: Object,
|
||||||
default: () => {}
|
default: () => {}
|
||||||
},
|
},
|
||||||
appId: String,
|
appId: String, // 仅分享链接有
|
||||||
log: Boolean,
|
log: Boolean,
|
||||||
record: {
|
record: {
|
||||||
type: Array<chatType[]>,
|
type: Array<chatType[]>,
|
||||||
@ -206,13 +206,26 @@ const chatList = ref<any[]>([])
|
|||||||
const isDisabledChart = computed(
|
const isDisabledChart = computed(
|
||||||
() => !(inputValue.value && (props.appId || (props.data?.name && props.data?.model_id)))
|
() => !(inputValue.value && (props.appId || (props.data?.name && props.data?.model_id)))
|
||||||
)
|
)
|
||||||
|
const isMdArray = (val: string) => val.match(/^-\s.*/m)
|
||||||
const prologueList = computed(() => {
|
const prologueList = computed(() => {
|
||||||
const temp = props.data?.prologue
|
const temp = props.data?.prologue
|
||||||
|
let arr: any = []
|
||||||
const lines = temp?.split('\n')
|
const lines = temp?.split('\n')
|
||||||
return lines
|
lines.forEach((str: string, index: number) => {
|
||||||
|
if (isMdArray(str)) {
|
||||||
|
arr[index] = {
|
||||||
|
type: 'question',
|
||||||
|
str: str.replace(/^-\s+/, '')
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
arr[index] = {
|
||||||
|
type: 'md',
|
||||||
|
str
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return arr
|
||||||
})
|
})
|
||||||
const isMdArray = (val: string) => val.match(/^-\s.*/m)
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.data,
|
() => props.data,
|
||||||
@ -414,7 +427,7 @@ function chatMessage() {
|
|||||||
return reader.read().then(write)
|
return reader.read().then(write)
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return getSourceDetail(chat)
|
return !props.appId && getSourceDetail(chat)
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
ChatManagement.close(chat.id)
|
ChatManagement.close(chat.id)
|
||||||
|
|||||||
@ -70,19 +70,6 @@ const rules = reactive({
|
|||||||
})
|
})
|
||||||
const FormRef = ref()
|
const FormRef = ref()
|
||||||
|
|
||||||
// const beforeUploadHandle: UploadProps['beforeUpload'] = (rawFile) => {
|
|
||||||
// const type = fileType(rawFile?.name)
|
|
||||||
// console.log(type)
|
|
||||||
// if (type !== 'txt' || type !== 'md') {
|
|
||||||
// MsgError('Avatar picture must be JPG format!')
|
|
||||||
// return false
|
|
||||||
// } else if (rawFile.size / 1024 / 1024 > 10) {
|
|
||||||
// MsgError('文件不超过 10MB!')
|
|
||||||
// return false
|
|
||||||
// }
|
|
||||||
// return true
|
|
||||||
// }
|
|
||||||
|
|
||||||
watch(form.value, (value) => {
|
watch(form.value, (value) => {
|
||||||
dataset.saveDocumentsFile(value.fileList)
|
dataset.saveDocumentsFile(value.fileList)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -53,7 +53,7 @@
|
|||||||
<el-form-item label="选择器" v-if="form.type === '1'">
|
<el-form-item label="选择器" v-if="form.type === '1'">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="form.selector"
|
v-model="form.selector"
|
||||||
placeholder="请输入选择器"
|
placeholder="默认为 body,可输入 .classname/#idname/tagname"
|
||||||
@blur="form.selector = form.selector.trim()"
|
@blur="form.selector = form.selector.trim()"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -71,7 +71,7 @@ import BaseForm from '@/views/dataset/component/BaseForm.vue'
|
|||||||
import UploadComponent from '@/views/dataset/component/UploadComponent.vue'
|
import UploadComponent from '@/views/dataset/component/UploadComponent.vue'
|
||||||
import { isAllPropertiesEmpty } from '@/utils/utils'
|
import { isAllPropertiesEmpty } from '@/utils/utils'
|
||||||
import datasetApi from '@/api/dataset'
|
import datasetApi from '@/api/dataset'
|
||||||
import { MsgConfirm, MsgSuccess } from '@/utils/message'
|
import { MsgError, MsgSuccess } from '@/utils/message'
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
const { dataset } = useStore()
|
const { dataset } = useStore()
|
||||||
|
|
||||||
@ -114,12 +114,17 @@ const onSubmit = async () => {
|
|||||||
if (isCreate) {
|
if (isCreate) {
|
||||||
if (form.value.type === '0') {
|
if (form.value.type === '0') {
|
||||||
if ((await BaseFormRef.value?.validate()) && (await UploadComponentRef.value.validate())) {
|
if ((await BaseFormRef.value?.validate()) && (await UploadComponentRef.value.validate())) {
|
||||||
/*
|
if (UploadComponentRef.value.form.fileList.length > 50) {
|
||||||
|
MsgError('每次最多上传50个文件!')
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
stores保存数据
|
stores保存数据
|
||||||
*/
|
*/
|
||||||
dataset.saveBaseInfo(BaseFormRef.value.form)
|
dataset.saveBaseInfo(BaseFormRef.value.form)
|
||||||
dataset.saveDocumentsFile(UploadComponentRef.value.form.fileList)
|
dataset.saveDocumentsFile(UploadComponentRef.value.form.fileList)
|
||||||
return true
|
return true
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,7 +93,7 @@ const open = (data: any) => {
|
|||||||
detail.value.content = data.content
|
detail.value.content = data.content
|
||||||
problemId.value = data.id
|
problemId.value = data.id
|
||||||
document_id.value = data.document_id
|
document_id.value = data.document_id
|
||||||
dataset_id.value = data.dataset_id
|
dataset_id.value = data.dataset_id || id
|
||||||
} else {
|
} else {
|
||||||
isEdit.value = true
|
isEdit.value = true
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user