fix: Please remove the default prompt words after uploading files for the dialogue interface and debugging interface (#3949)

v3.2
shaohuzhang1 2025-08-27 18:34:58 +08:00 committed by GitHub
parent a0bca36341
commit f12ba4eeeb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 56 additions and 19 deletions

View File

@ -356,7 +356,9 @@ const localLoading = computed({
}, },
}) })
const uploadLoading = ref(false) const uploadLoading = computed(() => {
return Object.values(filePromisionDict.value).length > 0
})
const inputPlaceholder = computed(() => { const inputPlaceholder = computed(() => {
return recorderStatus.value === 'START' return recorderStatus.value === 'START'
@ -411,7 +413,7 @@ const checkMaxFilesLimit = () => {
uploadOtherList.value.length uploadOtherList.value.length
) )
} }
const filePromisionDict: any = ref<any>({})
const uploadFile = async (file: any, fileList: any) => { const uploadFile = async (file: any, fileList: any) => {
const { maxFiles, fileLimit } = props.applicationDetails.file_upload_setting const { maxFiles, fileLimit } = props.applicationDetails.file_upload_setting
// //
@ -445,6 +447,7 @@ const uploadFile = async (file: any, fileList: any) => {
) )
return return
} }
filePromisionDict.value[file.uid] = false
const inner = reactive(file) const inner = reactive(file)
fileAllList.value.push(inner) fileAllList.value.push(inner)
if (!chatId_context.value) { if (!chatId_context.value) {
@ -453,23 +456,15 @@ const uploadFile = async (file: any, fileList: any) => {
} }
const api = const api =
props.type === 'debug-ai-chat' props.type === 'debug-ai-chat'
? applicationApi.postUploadFile( ? applicationApi.postUploadFile(file.raw, 'TEMPORARY_120_MINUTE', 'TEMPORARY_120_MINUTE')
file.raw, : chatAPI.postUploadFile(file.raw, chatId_context.value, 'CHAT')
'TEMPORARY_120_MINUTE',
'TEMPORARY_120_MINUTE',
uploadLoading,
)
: chatAPI.postUploadFile(file.raw, chatId_context.value, 'CHAT', uploadLoading)
api.then((ok) => { api.then((ok) => {
inner.url = ok.data inner.url = ok.data
const split_path = ok.data.split('/') const split_path = ok.data.split('/')
inner.file_id = split_path[split_path.length - 1] 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) => { const handlePaste = (event: ClipboardEvent) => {
@ -549,8 +544,18 @@ const uploadOtherList = computed(() =>
const showDelete = ref('') const showDelete = ref('')
const isDisabledChat = computed( 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 isMicrophone = ref(false)
const switchMicrophone = (status: boolean) => { 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() { function autoSendMessage() {
props props
.validate() .validate()
.then(() => { .then(() => {
props.sendMessage(inputValue.value, { props.sendMessage(getQuestion(), {
image_list: uploadImageList.value, image_list: uploadImageList.value,
document_list: uploadDocumentList.value, document_list: uploadDocumentList.value,
audio_list: uploadAudioList.value, audio_list: uploadAudioList.value,
@ -797,7 +825,7 @@ function sendChatHandle(event?: any) {
// //
event?.preventDefault() event?.preventDefault()
if (!isDisabledChat.value && !props.loading && !event?.isComposing && !uploadLoading.value) { if (!isDisabledChat.value && !props.loading && !event?.isComposing && !uploadLoading.value) {
if (inputValue.value.trim()) { if (inputValue.value.trim() || fileAllList.value.length > 0) {
autoSendMessage() autoSendMessage()
} }
} }

View File

@ -74,8 +74,11 @@ export default {
sizeLimit: 'Each file must not exceed', sizeLimit: 'Each file must not exceed',
sizeLimit2: 'Empty files are not supported for upload', sizeLimit2: 'Empty files are not supported for upload',
imageMessage: 'Please process the image content', 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', errorMessage: 'Upload Failed',
fileMessage: 'Please process the file content',
fileRepeat: 'File already exists', fileRepeat: 'File already exists',
}, },
executionDetails: { executionDetails: {

View File

@ -72,8 +72,11 @@ export default {
sizeLimit: '单个文件大小不能超过', sizeLimit: '单个文件大小不能超过',
sizeLimit2: '空文件不支持上传', sizeLimit2: '空文件不支持上传',
imageMessage: '请解析图片内容', imageMessage: '请解析图片内容',
fileMessage: '请解析文件内容', documentMessage: '请理解文档内容',
audioMessage: '请理解音频内容',
otherMessage: '请理解文件内容',
errorMessage: '上传失败', errorMessage: '上传失败',
fileMessage: '请解析文件内容',
fileRepeat: '文件已存在', fileRepeat: '文件已存在',
}, },
executionDetails: { executionDetails: {

View File

@ -72,6 +72,9 @@ export default {
sizeLimit: '單個文件大小不能超過', sizeLimit: '單個文件大小不能超過',
sizeLimit2: '空文件不支持上傳', sizeLimit2: '空文件不支持上傳',
imageMessage: '請解析圖片內容', imageMessage: '請解析圖片內容',
documentMessage: '請理解檔案內容',
audioMessage: '請理解音訊內容',
otherMessage: '請理解檔案內容',
fileMessage: '請解析文件內容', fileMessage: '請解析文件內容',
errorMessage: '上傳失敗', errorMessage: '上傳失敗',
fileRepeat: '文件已存在', fileRepeat: '文件已存在',