From f12ba4eeebe3f3a9cbc14ff364ecead4b53023ce Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Wed, 27 Aug 2025 18:34:58 +0800 Subject: [PATCH] fix: Please remove the default prompt words after uploading files for the dialogue interface and debugging interface (#3949) --- .../component/chat-input-operate/index.vue | 62 ++++++++++++++----- ui/src/locales/lang/en-US/ai-chat.ts | 5 +- ui/src/locales/lang/zh-CN/ai-chat.ts | 5 +- ui/src/locales/lang/zh-Hant/ai-chat.ts | 3 + 4 files changed, 56 insertions(+), 19 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 127f0e3e3..00a3d6421 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 @@ -356,7 +356,9 @@ const localLoading = computed({ }, }) -const uploadLoading = ref(false) +const uploadLoading = computed(() => { + return Object.values(filePromisionDict.value).length > 0 +}) const inputPlaceholder = computed(() => { return recorderStatus.value === 'START' @@ -411,7 +413,7 @@ const checkMaxFilesLimit = () => { uploadOtherList.value.length ) } - +const filePromisionDict: any = ref({}) const uploadFile = async (file: any, fileList: any) => { const { maxFiles, fileLimit } = props.applicationDetails.file_upload_setting // 单次上传文件数量限制 @@ -445,6 +447,7 @@ const uploadFile = async (file: any, fileList: any) => { ) return } + filePromisionDict.value[file.uid] = false const inner = reactive(file) fileAllList.value.push(inner) if (!chatId_context.value) { @@ -453,23 +456,15 @@ const uploadFile = async (file: any, fileList: any) => { } const api = props.type === 'debug-ai-chat' - ? applicationApi.postUploadFile( - file.raw, - 'TEMPORARY_120_MINUTE', - 'TEMPORARY_120_MINUTE', - uploadLoading, - ) - : chatAPI.postUploadFile(file.raw, chatId_context.value, 'CHAT', uploadLoading) + ? applicationApi.postUploadFile(file.raw, 'TEMPORARY_120_MINUTE', 'TEMPORARY_120_MINUTE') + : chatAPI.postUploadFile(file.raw, chatId_context.value, 'CHAT') + api.then((ok) => { inner.url = ok.data const split_path = ok.data.split('/') inner.file_id = split_path[split_path.length - 1] + delete filePromisionDict.value[file.uid] }) - if (!inputValue.value && uploadImageList.value.length > 0) { - inputValue.value = t('chat.uploadFile.imageMessage') - } else { - inputValue.value = t('chat.uploadFile.fileMessage') - } } // 粘贴处理 const handlePaste = (event: ClipboardEvent) => { @@ -549,8 +544,18 @@ const uploadOtherList = computed(() => const showDelete = ref('') const isDisabledChat = computed( - () => !(inputValue.value.trim() && (props.appId || props.applicationDetails?.name)), + () => + !( + (inputValue.value.trim() || + uploadImageList.value.length > 0 || + uploadDocumentList.value.length > 0 || + uploadVideoList.value.length > 0 || + uploadAudioList.value.length > 0 || + uploadOtherList.value.length > 0) && + (props.appId || props.applicationDetails?.name) + ), ) + // 是否显示移动端语音按钮 const isMicrophone = ref(false) const switchMicrophone = (status: boolean) => { @@ -758,11 +763,34 @@ const stopTimer = () => { } } +const getQuestion = () => { + if (!inputValue.value.trim()) { + const fileLenth = [ + uploadImageList.value.length > 0, + uploadDocumentList.value.length > 0, + uploadAudioList.value.length > 0, + uploadOtherList.value.length > 0, + ] + if (fileLenth.filter((f) => f).length > 1) { + return t('chat.uploadFile.otherMessage') + } else if (fileLenth[0]) { + return t('chat.uploadFile.imageMessage') + } else if (fileLenth[1]) { + return t('chat.uploadFile.documentMessage') + } else if (fileLenth[2]) { + return t('chat.uploadFile.audioMessage') + } else if (fileLenth[3]) { + return t('chat.uploadFile.otherMessage') + } + } + + return inputValue.value.trim() +} function autoSendMessage() { props .validate() .then(() => { - props.sendMessage(inputValue.value, { + props.sendMessage(getQuestion(), { image_list: uploadImageList.value, document_list: uploadDocumentList.value, audio_list: uploadAudioList.value, @@ -797,7 +825,7 @@ function sendChatHandle(event?: any) { // 如果没有按下组合键,则会阻止默认事件 event?.preventDefault() if (!isDisabledChat.value && !props.loading && !event?.isComposing && !uploadLoading.value) { - if (inputValue.value.trim()) { + if (inputValue.value.trim() || fileAllList.value.length > 0) { autoSendMessage() } } diff --git a/ui/src/locales/lang/en-US/ai-chat.ts b/ui/src/locales/lang/en-US/ai-chat.ts index f1450f95f..29497cb05 100644 --- a/ui/src/locales/lang/en-US/ai-chat.ts +++ b/ui/src/locales/lang/en-US/ai-chat.ts @@ -74,8 +74,11 @@ export default { sizeLimit: 'Each file must not exceed', sizeLimit2: 'Empty files are not supported for upload', imageMessage: 'Please process the image content', - fileMessage: 'Please process the file content', + documentMessage: 'Please understand the content of the document', + audioMessage: 'Please understand the audio content', + otherMessage: 'Please understand the file content', errorMessage: 'Upload Failed', + fileMessage: 'Please process the file content', fileRepeat: 'File already exists', }, executionDetails: { diff --git a/ui/src/locales/lang/zh-CN/ai-chat.ts b/ui/src/locales/lang/zh-CN/ai-chat.ts index da43e45cb..81494bf0c 100644 --- a/ui/src/locales/lang/zh-CN/ai-chat.ts +++ b/ui/src/locales/lang/zh-CN/ai-chat.ts @@ -72,8 +72,11 @@ export default { sizeLimit: '单个文件大小不能超过', sizeLimit2: '空文件不支持上传', imageMessage: '请解析图片内容', - fileMessage: '请解析文件内容', + documentMessage: '请理解文档内容', + audioMessage: '请理解音频内容', + otherMessage: '请理解文件内容', errorMessage: '上传失败', + fileMessage: '请解析文件内容', fileRepeat: '文件已存在', }, executionDetails: { diff --git a/ui/src/locales/lang/zh-Hant/ai-chat.ts b/ui/src/locales/lang/zh-Hant/ai-chat.ts index bb9045352..830a545be 100644 --- a/ui/src/locales/lang/zh-Hant/ai-chat.ts +++ b/ui/src/locales/lang/zh-Hant/ai-chat.ts @@ -72,6 +72,9 @@ export default { sizeLimit: '單個文件大小不能超過', sizeLimit2: '空文件不支持上傳', imageMessage: '請解析圖片內容', + documentMessage: '請理解檔案內容', + audioMessage: '請理解音訊內容', + otherMessage: '請理解檔案內容', fileMessage: '請解析文件內容', errorMessage: '上傳失敗', fileRepeat: '文件已存在',