diff --git a/web/app/components/app/chat/answer/index.tsx b/web/app/components/app/chat/answer/index.tsx index 68615341ccd606..7138aeba881e40 100644 --- a/web/app/components/app/chat/answer/index.tsx +++ b/web/app/components/app/chat/answer/index.tsx @@ -49,7 +49,7 @@ export type IAnswerProps = { onQueryChange: (query: string) => void onFeedback?: FeedbackFunc displayScene: DisplayScene - isResponsing?: boolean + isResponding?: boolean answerIcon?: ReactNode citation?: CitationItem[] dataSets?: DataSet[] @@ -74,7 +74,7 @@ const Answer: FC = ({ isHideFeedbackEdit = false, onFeedback, displayScene = 'web', - isResponsing, + isResponding, answerIcon, citation, isShowCitation, @@ -229,7 +229,7 @@ const Answer: FC = ({ )} @@ -248,7 +248,7 @@ const Answer: FC = ({ { answerIcon || (
- {isResponsing + {isResponding &&
@@ -260,7 +260,7 @@ const Answer: FC = ({
- {(isResponsing && (isAgentMode ? (!content && (agent_thoughts || []).filter(item => !!item.thought || !!item.tool).length === 0) : !content)) + {(isResponding && (isAgentMode ? (!content && (agent_thoughts || []).filter(item => !!item.thought || !!item.tool).length === 0) : !content)) ? (
@@ -314,7 +314,7 @@ const Answer: FC = ({
)} { - !!citation?.length && isShowCitation && !isResponsing && ( + !!citation?.length && isShowCitation && !isResponding && ( ) } diff --git a/web/app/components/app/chat/index.tsx b/web/app/components/app/chat/index.tsx index c683416b574364..0abdaab6d59de4 100644 --- a/web/app/components/app/chat/index.tsx +++ b/web/app/components/app/chat/index.tsx @@ -49,9 +49,9 @@ export type IChatProps = { onSend?: (message: string, files: VisionFile[]) => void displayScene?: DisplayScene useCurrentUserAvatar?: boolean - isResponsing?: boolean - canStopResponsing?: boolean - abortResponsing?: () => void + isResponding?: boolean + canStopResponding?: boolean + abortResponding?: () => void controlClearQuery?: number controlFocus?: number isShowSuggestion?: boolean @@ -82,9 +82,9 @@ const Chat: FC = ({ onSend = () => { }, displayScene, useCurrentUserAvatar, - isResponsing, - canStopResponsing, - abortResponsing, + isResponding, + canStopResponding, + abortResponding, controlClearQuery, controlFocus, isShowSuggestion, @@ -153,7 +153,7 @@ const Chat: FC = ({ if (!files.find(item => item.type === TransferMethod.local_file && !item.fileId)) { if (files.length) onClear() - if (!isResponsing) + if (!isResponding) onQueryChange('') } } @@ -286,7 +286,7 @@ const Chat: FC = ({ isHideFeedbackEdit={isHideFeedbackEdit} onFeedback={onFeedback} displayScene={displayScene ?? 'web'} - isResponsing={isResponsing && isLast} + isResponding={isResponding && isLast} answerIcon={answerIcon} citation={citation} dataSets={dataSets} @@ -311,7 +311,7 @@ const Chat: FC = ({ useCurrentUserAvatar={useCurrentUserAvatar} item={item} isShowPromptLog={isShowPromptLog} - isResponsing={isResponsing} + isResponding={isResponding} /> ) })} @@ -320,9 +320,9 @@ const Chat: FC = ({ !isHideSendInput && (
{/* Thinking is sync and can not be stopped */} - {(isResponsing && canStopResponsing && ((!!chatList[chatList.length - 1]?.content) || (chatList[chatList.length - 1]?.agent_thoughts && chatList[chatList.length - 1].agent_thoughts!.length > 0))) && ( + {(isResponding && canStopResponding && ((!!chatList[chatList.length - 1]?.content) || (chatList[chatList.length - 1]?.agent_thoughts && chatList[chatList.length - 1].agent_thoughts!.length > 0))) && (
- diff --git a/web/app/components/app/chat/question/index.tsx b/web/app/components/app/chat/question/index.tsx index e5806709ea2a1f..7006682f7c52dc 100644 --- a/web/app/components/app/chat/question/index.tsx +++ b/web/app/components/app/chat/question/index.tsx @@ -13,10 +13,10 @@ import ImageGallery from '@/app/components/base/image-gallery' type IQuestionProps = Pick & { isShowPromptLog?: boolean item: IChatItem - isResponsing?: boolean + isResponding?: boolean } -const Question: FC = ({ id, content, more, useCurrentUserAvatar, isShowPromptLog, item, isResponsing }) => { +const Question: FC = ({ id, content, more, useCurrentUserAvatar, isShowPromptLog, item, isResponding }) => { const { userProfile } = useContext(AppContext) const userName = userProfile?.name const ref = useRef(null) @@ -28,7 +28,7 @@ const Question: FC = ({ id, content, more, useCurrentUserAvatar,
{ - isShowPromptLog && !isResponsing && ( + isShowPromptLog && !isResponding && ( ) } diff --git a/web/app/components/app/configuration/debug/debug-with-multiple-model/chat-item.tsx b/web/app/components/app/configuration/debug/debug-with-multiple-model/chat-item.tsx index 2178527e4b92f7..6c6722a8ecf46e 100644 --- a/web/app/components/app/configuration/debug/debug-with-multiple-model/chat-item.tsx +++ b/web/app/components/app/configuration/debug/debug-with-multiple-model/chat-item.tsx @@ -46,7 +46,7 @@ const ChatItem: FC = ({ const config = useConfigFromDebugContext() const { chatList, - isResponsing, + isResponding, handleSend, suggestedQuestions, handleRestart, @@ -118,7 +118,7 @@ const ChatItem: FC = ({ = ({ const { completion, handleSend, - isResponsing, + isResponding, messageId, } = useTextGeneration() @@ -143,8 +143,8 @@ const TextGenerationItem: FC = ({ innerClassName='grow flex flex-col' contentClassName='grow' content={completion} - isLoading={!completion && isResponsing} - isResponsing={isResponsing} + isLoading={!completion && isResponding} + isResponding={isResponding} isInstalledApp={false} messageId={messageId} isError={false} diff --git a/web/app/components/app/configuration/debug/debug-with-single-model/index.tsx b/web/app/components/app/configuration/debug/debug-with-single-model/index.tsx index 6a8a416e816d8f..a14211efa1a5e1 100644 --- a/web/app/components/app/configuration/debug/debug-with-single-model/index.tsx +++ b/web/app/components/app/configuration/debug/debug-with-single-model/index.tsx @@ -45,7 +45,7 @@ const DebugWithSingleModel = forwardRef = ({ } }, []) - const [isResponsing, { setTrue: setResponsingTrue, setFalse: setResponsingFalse }] = useBoolean(false) + const [isResponding, { setTrue: setRespondingTrue, setFalse: setRespondingFalse }] = useBoolean(false) const [isShowFormattingChangeConfirm, setIsShowFormattingChangeConfirm] = useState(false) const [isShowCannotQueryDataset, setShowCannotQueryDataset] = useState(false) @@ -191,7 +191,7 @@ const Debug: FC = ({ const [messageId, setMessageId] = useState(null) const sendTextCompletion = async () => { - if (isResponsing) { + if (isResponding) { notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') }) return false } @@ -277,7 +277,7 @@ const Debug: FC = ({ setMessageId('') let res: string[] = [] - setResponsingTrue() + setRespondingTrue() sendCompletionMessage(appId, data, { onData: (data: string, _isFirstMessage: boolean, { messageId }) => { res.push(data) @@ -289,10 +289,10 @@ const Debug: FC = ({ setCompletionRes(res.join('')) }, onCompleted() { - setResponsingFalse() + setRespondingFalse() }, onError() { - setResponsingFalse() + setRespondingFalse() }, }) } @@ -440,13 +440,13 @@ const Debug: FC = ({ {mode === AppType.completion && (
- {(completionRes || isResponsing) && ( + {(completionRes || isResponding) && ( = ({ content, messageId, isLoading, - isResponsing, + isResponding, moreLikeThis, isInWebApp = false, feedback, @@ -277,7 +277,7 @@ const GenerationItem: FC = ({
{ - !isInWebApp && !isInstalledApp && !isResponsing && ( + !isInWebApp && !isInstalledApp && !isResponding && ( { chatList, handleSend, handleStop, - isResponsing, + isResponding, suggestedQuestions, } = useChat( appConfig, @@ -130,7 +130,7 @@ const ChatWrapper = () => { } const AgentContent: FC = ({ item, - responsing, + responding, allToolIcons, }) => { const { @@ -46,7 +46,7 @@ const AgentContent: FC = ({ )} diff --git a/web/app/components/base/chat/chat/answer/index.tsx b/web/app/components/base/chat/chat/answer/index.tsx index 088336c00b1874..84b397462c4525 100644 --- a/web/app/components/base/chat/chat/answer/index.tsx +++ b/web/app/components/base/chat/chat/answer/index.tsx @@ -25,7 +25,7 @@ type AnswerProps = { index: number config?: ChatConfig answerIcon?: ReactNode - responsing?: boolean + responding?: boolean allToolIcons?: Record } const Answer: FC = ({ @@ -34,7 +34,7 @@ const Answer: FC = ({ index, config, answerIcon, - responsing, + responding, allToolIcons, }) => { const { t } = useTranslation() @@ -58,7 +58,7 @@ const Answer: FC = ({ ) } { - responsing && ( + responding && (
@@ -70,7 +70,7 @@ const Answer: FC = ({
{ - !responsing && ( + !responding && ( = ({ ) } { - responsing && !content && !hasAgentThoughts && ( + responding && !content && !hasAgentThoughts && (
@@ -94,7 +94,7 @@ const Answer: FC = ({ hasAgentThoughts && ( ) @@ -109,7 +109,7 @@ const Answer: FC = ({ } { - !!citation?.length && config?.retriever_resource?.enabled && !responsing && ( + !!citation?.length && config?.retriever_resource?.enabled && !responding && ( ) } diff --git a/web/app/components/base/chat/chat/context.tsx b/web/app/components/base/chat/chat/context.tsx index a2086e0819efd7..ba6f67189e1cc9 100644 --- a/web/app/components/base/chat/chat/context.tsx +++ b/web/app/components/base/chat/chat/context.tsx @@ -5,7 +5,7 @@ import { createContext, useContext } from 'use-context-selector' import type { ChatProps } from './index' export type ChatContextValue = Pick(prevChatList || []) const chatListRef = useRef(prevChatList || []) const taskIdRef = useRef('') @@ -101,9 +101,9 @@ export const useChat = ( setChatList(newChatList) chatListRef.current = newChatList }, []) - const handleResponsing = useCallback((isResponsing: boolean) => { - setIsResponsing(isResponsing) - isResponsingRef.current = isResponsing + const handleResponding = useCallback((isResponding: boolean) => { + setIsResponding(isResponding) + isRespondingRef.current = isResponding }, []) const getIntroduction = useCallback((str: string) => { @@ -136,14 +136,14 @@ export const useChat = ( const handleStop = useCallback(() => { hasStopResponded.current = true - handleResponsing(false) + handleResponding(false) if (stopChat && taskIdRef.current) stopChat(taskIdRef.current) if (conversationMessagesAbortControllerRef.current) conversationMessagesAbortControllerRef.current.abort() if (suggestedQuestionsAbortControllerRef.current) suggestedQuestionsAbortControllerRef.current.abort() - }, [stopChat, handleResponsing]) + }, [stopChat, handleResponding]) const handleRestart = useCallback(() => { connversationId.current = '' @@ -200,7 +200,7 @@ export const useChat = ( ) => { setSuggestQuestions([]) - if (isResponsingRef.current) { + if (isRespondingRef.current) { notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') }) return false } @@ -235,7 +235,7 @@ export const useChat = ( isAnswer: true, } - handleResponsing(true) + handleResponding(true) hasStopResponded.current = false const bodyParams = { @@ -295,7 +295,7 @@ export const useChat = ( }) }, async onCompleted(hasError?: boolean) { - handleResponsing(false) + handleResponding(false) if (hasError) return @@ -416,7 +416,7 @@ export const useChat = ( responseItem.content = messageReplace.answer }, onError() { - handleResponsing(false) + handleResponding(false) const newChatList = produce(chatListRef.current, (draft) => { draft.splice(draft.findIndex(item => item.id === placeholderAnswerId), 1) }) @@ -432,7 +432,7 @@ export const useChat = ( notify, promptVariablesConfig, handleUpdateChatList, - handleResponsing, + handleResponding, ]) const handleAnnotationEdited = useCallback((query: string, answer: string, index: number) => { @@ -506,8 +506,8 @@ export const useChat = ( chatList, setChatList, conversationId: connversationId.current, - isResponsing, - setIsResponsing, + isResponding, + setIsResponding, handleSend, suggestedQuestions, handleRestart, diff --git a/web/app/components/base/chat/chat/index.tsx b/web/app/components/base/chat/chat/index.tsx index 67a91e21506c27..2f3ae501314ab1 100644 --- a/web/app/components/base/chat/chat/index.tsx +++ b/web/app/components/base/chat/chat/index.tsx @@ -28,7 +28,7 @@ import { StopCircle } from '@/app/components/base/icons/src/vender/solid/mediaAn export type ChatProps = { chatList: ChatItem[] config?: ChatConfig - isResponsing?: boolean + isResponding?: boolean noStopResponding?: boolean onStopResponding?: () => void noChatInput?: boolean @@ -52,7 +52,7 @@ const Chat: FC = ({ config, onSend, chatList, - isResponsing, + isResponding, noStopResponding, onStopResponding, noChatInput, @@ -125,7 +125,7 @@ const Chat: FC = ({ = ({ index={index} config={config} answerIcon={answerIcon} - responsing={isLast && isResponsing} + responding={isLast && isResponding} allToolIcons={allToolIcons} /> ) @@ -169,7 +169,7 @@ const Chat: FC = ({ item={item} showPromptLog={showPromptLog} questionIcon={questionIcon} - isResponsing={isResponsing} + isResponding={isResponding} /> ) }) @@ -188,7 +188,7 @@ const Chat: FC = ({ className={`${chatFooterInnerClassName}`} > { - !noStopResponding && isResponsing && ( + !noStopResponding && isResponding && (