From 78fa4af45a762a9c50b15f2152bab445a80eba67 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Tue, 23 Jan 2024 16:39:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ai-chat/ParagraphSourceDialog.vue | 102 ++++++++++-------- ui/src/components/ai-chat/index.vue | 31 ++++-- .../dataset/component/UploadComponent.vue | 13 --- ui/src/views/dataset/step/StepFirst.vue | 17 +-- .../paragraph/component/ParagraphDialog.vue | 2 +- 5 files changed, 94 insertions(+), 71 deletions(-) diff --git a/ui/src/components/ai-chat/ParagraphSourceDialog.vue b/ui/src/components/ai-chat/ParagraphSourceDialog.vue index dad7b2006..21276bec4 100644 --- a/ui/src/components/ai-chat/ParagraphSourceDialog.vue +++ b/ui/src/components/ai-chat/ParagraphSourceDialog.vue @@ -1,48 +1,56 @@ @@ -71,7 +79,12 @@ const open = (data: any, id?: string) => { defineExpose({ open }) - diff --git a/ui/src/components/ai-chat/index.vue b/ui/src/components/ai-chat/index.vue index c1bf639d8..f4215b4b9 100644 --- a/ui/src/components/ai-chat/index.vue +++ b/ui/src/components/ai-chat/index.vue @@ -13,20 +13,20 @@ @@ -184,7 +184,7 @@ const props = defineProps({ type: Object, default: () => {} }, - appId: String, + appId: String, // 仅分享链接有 log: Boolean, record: { type: Array, @@ -206,13 +206,26 @@ const chatList = ref([]) 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) diff --git a/ui/src/views/dataset/component/UploadComponent.vue b/ui/src/views/dataset/component/UploadComponent.vue index 7762ea9be..e6e834ebd 100644 --- a/ui/src/views/dataset/component/UploadComponent.vue +++ b/ui/src/views/dataset/component/UploadComponent.vue @@ -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) }) diff --git a/ui/src/views/dataset/step/StepFirst.vue b/ui/src/views/dataset/step/StepFirst.vue index f5eaebfcc..4fe036f32 100644 --- a/ui/src/views/dataset/step/StepFirst.vue +++ b/ui/src/views/dataset/step/StepFirst.vue @@ -53,7 +53,7 @@ @@ -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 } diff --git a/ui/src/views/paragraph/component/ParagraphDialog.vue b/ui/src/views/paragraph/component/ParagraphDialog.vue index 575247b68..de49f7e56 100644 --- a/ui/src/views/paragraph/component/ParagraphDialog.vue +++ b/ui/src/views/paragraph/component/ParagraphDialog.vue @@ -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 }