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