From 805ed84f61f663188e58abe4fc8ec6aabaa5a8bb Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Mon, 5 Feb 2024 13:22:05 +0800 Subject: [PATCH] chore: enchange pic uploading tip (#2388) Co-authored-by: Joel --- web/app/components/base/chat/chat/chat-input.tsx | 13 +++++++++---- web/app/components/base/chat/chat/hooks.ts | 3 +-- .../share/text-generation/result/index.tsx | 7 ++++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/web/app/components/base/chat/chat/chat-input.tsx b/web/app/components/base/chat/chat/chat-input.tsx index 9eee122b01..2c8a308b0d 100644 --- a/web/app/components/base/chat/chat/chat-input.tsx +++ b/web/app/components/base/chat/chat/chat-input.tsx @@ -62,6 +62,14 @@ const ChatInput: FC = ({ const handleSend = () => { if (onSend) { + if (files.find(item => item.type === TransferMethod.local_file && !item.fileId)) { + notify({ type: 'info', message: t('appDebug.errorMessage.waitForImgUpload') }) + return + } + if (!query || !query.trim()) { + notify({ type: 'info', message: t('appAnnotation.errorMessage.queryRequired') }) + return + } onSend(query, files.filter(file => file.progress !== -1).map(fileItem => ({ type: 'image', transfer_method: fileItem.type, @@ -69,10 +77,7 @@ const ChatInput: FC = ({ upload_file_id: fileItem.fileId, }))) setQuery('') - } - if (!files.find(item => item.type === TransferMethod.local_file && !item.fileId)) { - if (files.length) - onClear() + onClear() } } diff --git a/web/app/components/base/chat/chat/hooks.ts b/web/app/components/base/chat/chat/hooks.ts index 71e76f26ad..819b7ae9d6 100644 --- a/web/app/components/base/chat/chat/hooks.ts +++ b/web/app/components/base/chat/chat/hooks.ts @@ -189,8 +189,7 @@ export const useChat = ( }: SendCallback, ) => { setSuggestQuestions([]) - if (!data.query || !data.query.trim()) - return + if (isResponsingRef.current) { notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') }) return false diff --git a/web/app/components/share/text-generation/result/index.tsx b/web/app/components/share/text-generation/result/index.tsx index 5616420584..d75fbcc8f0 100644 --- a/web/app/components/share/text-generation/result/index.tsx +++ b/web/app/components/share/text-generation/result/index.tsx @@ -96,8 +96,13 @@ const Result: FC = ({ return true const prompt_variables = promptConfig?.prompt_variables - if (!prompt_variables || prompt_variables?.length === 0) + if (!prompt_variables || prompt_variables?.length === 0) { + if (completionFiles.find(item => item.transfer_method === TransferMethod.local_file && !item.upload_file_id)) { + notify({ type: 'info', message: t('appDebug.errorMessage.waitForImgUpload') }) + return false + } return true + } let hasEmptyInput = '' const requiredVars = prompt_variables?.filter(({ key, name, required }) => {