Skip to content

Commit 66e180a

Browse files
committed
fix: Please remove the default prompt words after uploading files for the dialogue interface and debugging interface
1 parent dbfdc73 commit 66e180a

File tree

4 files changed

+56
-19
lines changed

4 files changed

+56
-19
lines changed

ui/src/components/ai-chat/component/chat-input-operate/index.vue

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,9 @@ const localLoading = computed({
356356
},
357357
})
358358
359-
const uploadLoading = ref(false)
359+
const uploadLoading = computed(() => {
360+
return Object.values(filePromisionDict.value).length > 0
361+
})
360362
361363
const inputPlaceholder = computed(() => {
362364
return recorderStatus.value === 'START'
@@ -411,7 +413,7 @@ const checkMaxFilesLimit = () => {
411413
uploadOtherList.value.length
412414
)
413415
}
414-
416+
const filePromisionDict: any = ref<any>({})
415417
const uploadFile = async (file: any, fileList: any) => {
416418
const { maxFiles, fileLimit } = props.applicationDetails.file_upload_setting
417419
// 单次上传文件数量限制
@@ -445,6 +447,7 @@ const uploadFile = async (file: any, fileList: any) => {
445447
)
446448
return
447449
}
450+
filePromisionDict.value[file.uid] = false
448451
const inner = reactive(file)
449452
fileAllList.value.push(inner)
450453
if (!chatId_context.value) {
@@ -453,23 +456,15 @@ const uploadFile = async (file: any, fileList: any) => {
453456
}
454457
const api =
455458
props.type === 'debug-ai-chat'
456-
? applicationApi.postUploadFile(
457-
file.raw,
458-
'TEMPORARY_120_MINUTE',
459-
'TEMPORARY_120_MINUTE',
460-
uploadLoading,
461-
)
462-
: chatAPI.postUploadFile(file.raw, chatId_context.value, 'CHAT', uploadLoading)
459+
? applicationApi.postUploadFile(file.raw, 'TEMPORARY_120_MINUTE', 'TEMPORARY_120_MINUTE')
460+
: chatAPI.postUploadFile(file.raw, chatId_context.value, 'CHAT')
461+
463462
api.then((ok) => {
464463
inner.url = ok.data
465464
const split_path = ok.data.split('/')
466465
inner.file_id = split_path[split_path.length - 1]
466+
delete filePromisionDict.value[file.uid]
467467
})
468-
if (!inputValue.value && uploadImageList.value.length > 0) {
469-
inputValue.value = t('chat.uploadFile.imageMessage')
470-
} else {
471-
inputValue.value = t('chat.uploadFile.fileMessage')
472-
}
473468
}
474469
// 粘贴处理
475470
const handlePaste = (event: ClipboardEvent) => {
@@ -549,8 +544,18 @@ const uploadOtherList = computed(() =>
549544
const showDelete = ref('')
550545
551546
const isDisabledChat = computed(
552-
() => !(inputValue.value.trim() && (props.appId || props.applicationDetails?.name)),
547+
() =>
548+
!(
549+
(inputValue.value.trim() ||
550+
uploadImageList.value.length > 0 ||
551+
uploadDocumentList.value.length > 0 ||
552+
uploadVideoList.value.length > 0 ||
553+
uploadAudioList.value.length > 0 ||
554+
uploadOtherList.value.length > 0) &&
555+
(props.appId || props.applicationDetails?.name)
556+
),
553557
)
558+
554559
// 是否显示移动端语音按钮
555560
const isMicrophone = ref(false)
556561
const switchMicrophone = (status: boolean) => {
@@ -758,11 +763,34 @@ const stopTimer = () => {
758763
}
759764
}
760765
766+
const getQuestion = () => {
767+
if (!inputValue.value.trim()) {
768+
const fileLenth = [
769+
uploadImageList.value.length > 0,
770+
uploadDocumentList.value.length > 0,
771+
uploadAudioList.value.length > 0,
772+
uploadOtherList.value.length > 0,
773+
]
774+
if (fileLenth.filter((f) => f).length > 1) {
775+
return t('chat.uploadFile.otherMessage')
776+
} else if (fileLenth[0]) {
777+
return t('chat.uploadFile.imageMessage')
778+
} else if (fileLenth[1]) {
779+
return t('chat.uploadFile.documentMessage')
780+
} else if (fileLenth[2]) {
781+
return t('chat.uploadFile.audioMessage')
782+
} else if (fileLenth[3]) {
783+
return t('chat.uploadFile.otherMessage')
784+
}
785+
}
786+
787+
return inputValue.value.trim()
788+
}
761789
function autoSendMessage() {
762790
props
763791
.validate()
764792
.then(() => {
765-
props.sendMessage(inputValue.value, {
793+
props.sendMessage(getQuestion(), {
766794
image_list: uploadImageList.value,
767795
document_list: uploadDocumentList.value,
768796
audio_list: uploadAudioList.value,
@@ -797,7 +825,7 @@ function sendChatHandle(event?: any) {
797825
// 如果没有按下组合键,则会阻止默认事件
798826
event?.preventDefault()
799827
if (!isDisabledChat.value && !props.loading && !event?.isComposing && !uploadLoading.value) {
800-
if (inputValue.value.trim()) {
828+
if (inputValue.value.trim() || fileAllList.value.length > 0) {
801829
autoSendMessage()
802830
}
803831
}

ui/src/locales/lang/en-US/ai-chat.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,11 @@ export default {
7272
sizeLimit: 'Each file must not exceed',
7373
sizeLimit2: 'Empty files are not supported for upload',
7474
imageMessage: 'Please process the image content',
75-
fileMessage: 'Please process the file content',
75+
documentMessage: 'Please understand the content of the document',
76+
audioMessage: 'Please understand the audio content',
77+
otherMessage: 'Please understand the file content',
7678
errorMessage: 'Upload Failed',
79+
fileMessage: 'Please process the file content',
7780
},
7881
executionDetails: {
7982
title: 'Execution Details',

ui/src/locales/lang/zh-CN/ai-chat.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,11 @@ export default {
7474
sizeLimit: '单个文件大小不能超过',
7575
sizeLimit2: '空文件不支持上传',
7676
imageMessage: '请解析图片内容',
77-
fileMessage: '请解析文件内容',
77+
documentMessage: '请理解文档内容',
78+
audioMessage: '请理解音频内容',
79+
otherMessage: '请理解文件内容',
7880
errorMessage: '上传失败',
81+
fileMessage: '请解析文件内容',
7982
fileRepeat: '文件已存在',
8083
},
8184
executionDetails: {

ui/src/locales/lang/zh-Hant/ai-chat.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ export default {
7070
sizeLimit: '單個文件大小不能超過',
7171
sizeLimit2: '空文件不支持上傳',
7272
imageMessage: '請解析圖片內容',
73+
documentMessage: '請理解檔案內容',
74+
audioMessage: '請理解音訊內容',
75+
otherMessage: '請理解檔案內容',
7376
fileMessage: '請解析文件內容',
7477
errorMessage: '上傳失敗',
7578
},

0 commit comments

Comments
 (0)