From 5c64d630a0fce4fc5df6634e5874387ac3313b1d Mon Sep 17 00:00:00 2001 From: CaptainB Date: Fri, 6 Dec 2024 18:14:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E4=B8=8A=E4=BC=A0mp3?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/chat-input-operate/index.vue | 60 ++++++++++++++++--- .../component/FileUploadSettingDialog.vue | 17 ++++++ ui/src/workflow/nodes/start-node/index.vue | 6 ++ 3 files changed, 75 insertions(+), 8 deletions(-) diff --git a/ui/src/components/ai-chat/component/chat-input-operate/index.vue b/ui/src/components/ai-chat/component/chat-input-operate/index.vue index 004748175dc..3670b85379c 100644 --- a/ui/src/components/ai-chat/component/chat-input-operate/index.vue +++ b/ui/src/components/ai-chat/component/chat-input-operate/index.vue @@ -6,7 +6,7 @@
+
@@ -200,7 +221,7 @@ const localLoading = computed({ const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp'] const documentExtensions = ['pdf', 'docx', 'txt', 'xls', 'xlsx', 'md', 'html', 'csv'] const videoExtensions = ['mp4', 'avi', 'mov', 'mkv', 'flv'] -const audioExtensions = ['mp3', 'wav', 'aac', 'flac'] +const audioExtensions = ['mp3'] const getAcceptList = () => { const { image, document, audio, video } = props.applicationDetails.file_upload_setting @@ -227,14 +248,14 @@ const getAcceptList = () => { const checkMaxFilesLimit = () => { return ( props.applicationDetails.file_upload_setting.maxFiles <= - uploadImageList.value.length + uploadDocumentList.value.length + uploadImageList.value.length + uploadDocumentList.value.length + uploadAudioList.value.length + uploadVideoList.value.length ) } const uploadFile = async (file: any, fileList: any) => { const { maxFiles, fileLimit } = props.applicationDetails.file_upload_setting // 单次上传文件数量限制 - const file_limit_once = uploadImageList.value.length + uploadDocumentList.value.length + const file_limit_once = uploadImageList.value.length + uploadDocumentList.value.length + uploadAudioList.value.length + uploadVideoList.value.length if (file_limit_once >= maxFiles) { MsgWarning('最多上传' + maxFiles + '个文件') fileList.splice(0, fileList.length) @@ -257,9 +278,9 @@ const uploadFile = async (file: any, fileList: any) => { } else if (documentExtensions.includes(extension)) { uploadDocumentList.value.push(file) } else if (videoExtensions.includes(extension)) { - // videos.push(file) + uploadVideoList.value.push(file) } else if (audioExtensions.includes(extension)) { - // audios.push(file) + uploadAudioList.value.push(file) } @@ -297,7 +318,20 @@ const uploadFile = async (file: any, fileList: any) => { file.file_id = f[0].file_id } }) - console.log(uploadDocumentList.value, uploadImageList.value) + uploadAudioList.value.forEach((file: any) => { + const f = response.data.filter((f: any) => f.name === file.name) + if (f.length > 0) { + file.url = f[0].url + file.file_id = f[0].file_id + } + }) + uploadVideoList.value.forEach((file: any) => { + const f = response.data.filter((f: any) => f.name === file.name) + if (f.length > 0) { + file.url = f[0].url + file.file_id = f[0].file_id + } + }) }) } const recorderTime = ref(0) @@ -306,6 +340,8 @@ const recorderLoading = ref(false) const inputValue = ref('') const uploadImageList = ref>([]) const uploadDocumentList = ref>([]) +const uploadVideoList = ref>([]) +const uploadAudioList = ref>([]) const mediaRecorderStatus = ref(true) const showDelete = ref('') @@ -433,11 +469,15 @@ function sendChatHandle(event: any) { if (inputValue.value.trim()) { props.sendMessage(inputValue.value, { image_list: uploadImageList.value, - document_list: uploadDocumentList.value + document_list: uploadDocumentList.value, + audio_list: uploadAudioList.value, + video_list: uploadVideoList.value, }) inputValue.value = '' uploadImageList.value = [] uploadDocumentList.value = [] + uploadAudioList.value = [] + uploadVideoList.value = [] quickInputRef.value.textareaStyle.height = '45px' } } @@ -452,6 +492,10 @@ function deleteFile(index: number, val: string) { uploadImageList.value.splice(index, 1) } else if (val === 'document') { uploadDocumentList.value.splice(index, 1) + } else if (val === 'video') { + uploadVideoList.value.splice(index, 1) + } else if (val === 'audio') { + uploadAudioList.value.splice(index, 1) } } function mouseenter(row: any) { diff --git a/ui/src/workflow/nodes/base-node/component/FileUploadSettingDialog.vue b/ui/src/workflow/nodes/base-node/component/FileUploadSettingDialog.vue index 461b6e81d8a..05c67b9f8c0 100644 --- a/ui/src/workflow/nodes/base-node/component/FileUploadSettingDialog.vue +++ b/ui/src/workflow/nodes/base-node/component/FileUploadSettingDialog.vue @@ -68,6 +68,23 @@ + +
+
+ +
+

音频(MP3)

+ 所选模型支持接收音频或与语音转文本节点配合使用 +
+
+ +
+