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

This commit is contained in:
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(() => {
return recorderStatus.value === 'START'
@ -411,7 +413,7 @@ const checkMaxFilesLimit = () => {
uploadOtherList.value.length
)
}
const filePromisionDict: any = ref<any>({})
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()
}
}

View File

@ -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: {

View File

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

View File

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