mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 16:29:01 +08:00
fix typo: responsing -> responding (#2718)
Co-authored-by: OSS-MAOLONGDONG\kaihong <maolongdong@kaihong.com>
This commit is contained in:
parent
31070ffbca
commit
7052565380
@ -49,7 +49,7 @@ export type IAnswerProps = {
|
|||||||
onQueryChange: (query: string) => void
|
onQueryChange: (query: string) => void
|
||||||
onFeedback?: FeedbackFunc
|
onFeedback?: FeedbackFunc
|
||||||
displayScene: DisplayScene
|
displayScene: DisplayScene
|
||||||
isResponsing?: boolean
|
isResponding?: boolean
|
||||||
answerIcon?: ReactNode
|
answerIcon?: ReactNode
|
||||||
citation?: CitationItem[]
|
citation?: CitationItem[]
|
||||||
dataSets?: DataSet[]
|
dataSets?: DataSet[]
|
||||||
@ -74,7 +74,7 @@ const Answer: FC<IAnswerProps> = ({
|
|||||||
isHideFeedbackEdit = false,
|
isHideFeedbackEdit = false,
|
||||||
onFeedback,
|
onFeedback,
|
||||||
displayScene = 'web',
|
displayScene = 'web',
|
||||||
isResponsing,
|
isResponding,
|
||||||
answerIcon,
|
answerIcon,
|
||||||
citation,
|
citation,
|
||||||
isShowCitation,
|
isShowCitation,
|
||||||
@ -229,7 +229,7 @@ const Answer: FC<IAnswerProps> = ({
|
|||||||
<Thought
|
<Thought
|
||||||
thought={item}
|
thought={item}
|
||||||
allToolIcons={allToolIcons || {}}
|
allToolIcons={allToolIcons || {}}
|
||||||
isFinished={!!item.observation || !isResponsing}
|
isFinished={!!item.observation || !isResponding}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@ -248,7 +248,7 @@ const Answer: FC<IAnswerProps> = ({
|
|||||||
{
|
{
|
||||||
answerIcon || (
|
answerIcon || (
|
||||||
<div className={`${s.answerIcon} w-10 h-10 shrink-0`}>
|
<div className={`${s.answerIcon} w-10 h-10 shrink-0`}>
|
||||||
{isResponsing
|
{isResponding
|
||||||
&& <div className={s.typeingIcon}>
|
&& <div className={s.typeingIcon}>
|
||||||
<LoadingAnim type='avatar' />
|
<LoadingAnim type='avatar' />
|
||||||
</div>
|
</div>
|
||||||
@ -260,7 +260,7 @@ const Answer: FC<IAnswerProps> = ({
|
|||||||
<div className={`${s.answerWrap} ${showEdit ? 'w-full' : ''}`}>
|
<div className={`${s.answerWrap} ${showEdit ? 'w-full' : ''}`}>
|
||||||
<div className={`${s.answer} relative text-sm text-gray-900`}>
|
<div className={`${s.answer} relative text-sm text-gray-900`}>
|
||||||
<div className={'ml-2 py-3 px-4 bg-gray-100 rounded-tr-2xl rounded-b-2xl'}>
|
<div className={'ml-2 py-3 px-4 bg-gray-100 rounded-tr-2xl rounded-b-2xl'}>
|
||||||
{(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))
|
||||||
? (
|
? (
|
||||||
<div className='flex items-center justify-center w-6 h-5'>
|
<div className='flex items-center justify-center w-6 h-5'>
|
||||||
<LoadingAnim type='text' />
|
<LoadingAnim type='text' />
|
||||||
@ -314,7 +314,7 @@ const Answer: FC<IAnswerProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{
|
{
|
||||||
!!citation?.length && isShowCitation && !isResponsing && (
|
!!citation?.length && isShowCitation && !isResponding && (
|
||||||
<Citation data={citation} showHitInfo={isShowCitationHitInfo} />
|
<Citation data={citation} showHitInfo={isShowCitationHitInfo} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -49,9 +49,9 @@ export type IChatProps = {
|
|||||||
onSend?: (message: string, files: VisionFile[]) => void
|
onSend?: (message: string, files: VisionFile[]) => void
|
||||||
displayScene?: DisplayScene
|
displayScene?: DisplayScene
|
||||||
useCurrentUserAvatar?: boolean
|
useCurrentUserAvatar?: boolean
|
||||||
isResponsing?: boolean
|
isResponding?: boolean
|
||||||
canStopResponsing?: boolean
|
canStopResponding?: boolean
|
||||||
abortResponsing?: () => void
|
abortResponding?: () => void
|
||||||
controlClearQuery?: number
|
controlClearQuery?: number
|
||||||
controlFocus?: number
|
controlFocus?: number
|
||||||
isShowSuggestion?: boolean
|
isShowSuggestion?: boolean
|
||||||
@ -82,9 +82,9 @@ const Chat: FC<IChatProps> = ({
|
|||||||
onSend = () => { },
|
onSend = () => { },
|
||||||
displayScene,
|
displayScene,
|
||||||
useCurrentUserAvatar,
|
useCurrentUserAvatar,
|
||||||
isResponsing,
|
isResponding,
|
||||||
canStopResponsing,
|
canStopResponding,
|
||||||
abortResponsing,
|
abortResponding,
|
||||||
controlClearQuery,
|
controlClearQuery,
|
||||||
controlFocus,
|
controlFocus,
|
||||||
isShowSuggestion,
|
isShowSuggestion,
|
||||||
@ -153,7 +153,7 @@ const Chat: FC<IChatProps> = ({
|
|||||||
if (!files.find(item => item.type === TransferMethod.local_file && !item.fileId)) {
|
if (!files.find(item => item.type === TransferMethod.local_file && !item.fileId)) {
|
||||||
if (files.length)
|
if (files.length)
|
||||||
onClear()
|
onClear()
|
||||||
if (!isResponsing)
|
if (!isResponding)
|
||||||
onQueryChange('')
|
onQueryChange('')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -286,7 +286,7 @@ const Chat: FC<IChatProps> = ({
|
|||||||
isHideFeedbackEdit={isHideFeedbackEdit}
|
isHideFeedbackEdit={isHideFeedbackEdit}
|
||||||
onFeedback={onFeedback}
|
onFeedback={onFeedback}
|
||||||
displayScene={displayScene ?? 'web'}
|
displayScene={displayScene ?? 'web'}
|
||||||
isResponsing={isResponsing && isLast}
|
isResponding={isResponding && isLast}
|
||||||
answerIcon={answerIcon}
|
answerIcon={answerIcon}
|
||||||
citation={citation}
|
citation={citation}
|
||||||
dataSets={dataSets}
|
dataSets={dataSets}
|
||||||
@ -311,7 +311,7 @@ const Chat: FC<IChatProps> = ({
|
|||||||
useCurrentUserAvatar={useCurrentUserAvatar}
|
useCurrentUserAvatar={useCurrentUserAvatar}
|
||||||
item={item}
|
item={item}
|
||||||
isShowPromptLog={isShowPromptLog}
|
isShowPromptLog={isShowPromptLog}
|
||||||
isResponsing={isResponsing}
|
isResponding={isResponding}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
@ -320,9 +320,9 @@ const Chat: FC<IChatProps> = ({
|
|||||||
!isHideSendInput && (
|
!isHideSendInput && (
|
||||||
<div className={cn(!feedbackDisabled && '!left-3.5 !right-3.5', 'absolute z-10 bottom-0 left-0 right-0')}>
|
<div className={cn(!feedbackDisabled && '!left-3.5 !right-3.5', 'absolute z-10 bottom-0 left-0 right-0')}>
|
||||||
{/* Thinking is sync and can not be stopped */}
|
{/* 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))) && (
|
||||||
<div className='flex justify-center mb-4'>
|
<div className='flex justify-center mb-4'>
|
||||||
<Button className='flex items-center space-x-1 bg-white' onClick={() => abortResponsing?.()}>
|
<Button className='flex items-center space-x-1 bg-white' onClick={() => abortResponding?.()}>
|
||||||
{stopIcon}
|
{stopIcon}
|
||||||
<span className='text-xs text-gray-500 font-normal'>{t('appDebug.operation.stopResponding')}</span>
|
<span className='text-xs text-gray-500 font-normal'>{t('appDebug.operation.stopResponding')}</span>
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -13,10 +13,10 @@ import ImageGallery from '@/app/components/base/image-gallery'
|
|||||||
type IQuestionProps = Pick<IChatItem, 'id' | 'content' | 'more' | 'useCurrentUserAvatar'> & {
|
type IQuestionProps = Pick<IChatItem, 'id' | 'content' | 'more' | 'useCurrentUserAvatar'> & {
|
||||||
isShowPromptLog?: boolean
|
isShowPromptLog?: boolean
|
||||||
item: IChatItem
|
item: IChatItem
|
||||||
isResponsing?: boolean
|
isResponding?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const Question: FC<IQuestionProps> = ({ id, content, more, useCurrentUserAvatar, isShowPromptLog, item, isResponsing }) => {
|
const Question: FC<IQuestionProps> = ({ id, content, more, useCurrentUserAvatar, isShowPromptLog, item, isResponding }) => {
|
||||||
const { userProfile } = useContext(AppContext)
|
const { userProfile } = useContext(AppContext)
|
||||||
const userName = userProfile?.name
|
const userName = userProfile?.name
|
||||||
const ref = useRef(null)
|
const ref = useRef(null)
|
||||||
@ -28,7 +28,7 @@ const Question: FC<IQuestionProps> = ({ id, content, more, useCurrentUserAvatar,
|
|||||||
|
|
||||||
<div className={`${s.question} group relative text-sm text-gray-900`}>
|
<div className={`${s.question} group relative text-sm text-gray-900`}>
|
||||||
{
|
{
|
||||||
isShowPromptLog && !isResponsing && (
|
isShowPromptLog && !isResponding && (
|
||||||
<Log log={item.log!} containerRef={ref} />
|
<Log log={item.log!} containerRef={ref} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ const ChatItem: FC<ChatItemProps> = ({
|
|||||||
const config = useConfigFromDebugContext()
|
const config = useConfigFromDebugContext()
|
||||||
const {
|
const {
|
||||||
chatList,
|
chatList,
|
||||||
isResponsing,
|
isResponding,
|
||||||
handleSend,
|
handleSend,
|
||||||
suggestedQuestions,
|
suggestedQuestions,
|
||||||
handleRestart,
|
handleRestart,
|
||||||
@ -118,7 +118,7 @@ const ChatItem: FC<ChatItemProps> = ({
|
|||||||
<Chat
|
<Chat
|
||||||
config={config}
|
config={config}
|
||||||
chatList={chatList}
|
chatList={chatList}
|
||||||
isResponsing={isResponsing}
|
isResponding={isResponding}
|
||||||
noChatInput
|
noChatInput
|
||||||
noStopResponding
|
noStopResponding
|
||||||
chatContainerclassName='p-4'
|
chatContainerclassName='p-4'
|
||||||
|
@ -83,7 +83,7 @@ const TextGenerationItem: FC<TextGenerationItemProps> = ({
|
|||||||
const {
|
const {
|
||||||
completion,
|
completion,
|
||||||
handleSend,
|
handleSend,
|
||||||
isResponsing,
|
isResponding,
|
||||||
messageId,
|
messageId,
|
||||||
} = useTextGeneration()
|
} = useTextGeneration()
|
||||||
|
|
||||||
@ -143,8 +143,8 @@ const TextGenerationItem: FC<TextGenerationItemProps> = ({
|
|||||||
innerClassName='grow flex flex-col'
|
innerClassName='grow flex flex-col'
|
||||||
contentClassName='grow'
|
contentClassName='grow'
|
||||||
content={completion}
|
content={completion}
|
||||||
isLoading={!completion && isResponsing}
|
isLoading={!completion && isResponding}
|
||||||
isResponsing={isResponsing}
|
isResponding={isResponding}
|
||||||
isInstalledApp={false}
|
isInstalledApp={false}
|
||||||
messageId={messageId}
|
messageId={messageId}
|
||||||
isError={false}
|
isError={false}
|
||||||
|
@ -45,7 +45,7 @@ const DebugWithSingleModel = forwardRef<DebugWithSingleModelRefType, DebugWithSi
|
|||||||
const config = useConfigFromDebugContext()
|
const config = useConfigFromDebugContext()
|
||||||
const {
|
const {
|
||||||
chatList,
|
chatList,
|
||||||
isResponsing,
|
isResponding,
|
||||||
handleSend,
|
handleSend,
|
||||||
suggestedQuestions,
|
suggestedQuestions,
|
||||||
handleStop,
|
handleStop,
|
||||||
@ -118,7 +118,7 @@ const DebugWithSingleModel = forwardRef<DebugWithSingleModelRefType, DebugWithSi
|
|||||||
<Chat
|
<Chat
|
||||||
config={config}
|
config={config}
|
||||||
chatList={chatList}
|
chatList={chatList}
|
||||||
isResponsing={isResponsing}
|
isResponding={isResponding}
|
||||||
chatContainerclassName='p-6'
|
chatContainerclassName='p-6'
|
||||||
chatFooterClassName='px-6 pt-10 pb-4'
|
chatFooterClassName='px-6 pt-10 pb-4'
|
||||||
suggestedQuestions={suggestedQuestions}
|
suggestedQuestions={suggestedQuestions}
|
||||||
|
@ -93,7 +93,7 @@ const Debug: FC<IDebug> = ({
|
|||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const [isResponsing, { setTrue: setResponsingTrue, setFalse: setResponsingFalse }] = useBoolean(false)
|
const [isResponding, { setTrue: setRespondingTrue, setFalse: setRespondingFalse }] = useBoolean(false)
|
||||||
const [isShowFormattingChangeConfirm, setIsShowFormattingChangeConfirm] = useState(false)
|
const [isShowFormattingChangeConfirm, setIsShowFormattingChangeConfirm] = useState(false)
|
||||||
const [isShowCannotQueryDataset, setShowCannotQueryDataset] = useState(false)
|
const [isShowCannotQueryDataset, setShowCannotQueryDataset] = useState(false)
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ const Debug: FC<IDebug> = ({
|
|||||||
const [messageId, setMessageId] = useState<string | null>(null)
|
const [messageId, setMessageId] = useState<string | null>(null)
|
||||||
|
|
||||||
const sendTextCompletion = async () => {
|
const sendTextCompletion = async () => {
|
||||||
if (isResponsing) {
|
if (isResponding) {
|
||||||
notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') })
|
notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') })
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -277,7 +277,7 @@ const Debug: FC<IDebug> = ({
|
|||||||
setMessageId('')
|
setMessageId('')
|
||||||
let res: string[] = []
|
let res: string[] = []
|
||||||
|
|
||||||
setResponsingTrue()
|
setRespondingTrue()
|
||||||
sendCompletionMessage(appId, data, {
|
sendCompletionMessage(appId, data, {
|
||||||
onData: (data: string, _isFirstMessage: boolean, { messageId }) => {
|
onData: (data: string, _isFirstMessage: boolean, { messageId }) => {
|
||||||
res.push(data)
|
res.push(data)
|
||||||
@ -289,10 +289,10 @@ const Debug: FC<IDebug> = ({
|
|||||||
setCompletionRes(res.join(''))
|
setCompletionRes(res.join(''))
|
||||||
},
|
},
|
||||||
onCompleted() {
|
onCompleted() {
|
||||||
setResponsingFalse()
|
setRespondingFalse()
|
||||||
},
|
},
|
||||||
onError() {
|
onError() {
|
||||||
setResponsingFalse()
|
setRespondingFalse()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -440,13 +440,13 @@ const Debug: FC<IDebug> = ({
|
|||||||
{mode === AppType.completion && (
|
{mode === AppType.completion && (
|
||||||
<div className="mt-6 px-6 pb-4">
|
<div className="mt-6 px-6 pb-4">
|
||||||
<GroupName name={t('appDebug.result')} />
|
<GroupName name={t('appDebug.result')} />
|
||||||
{(completionRes || isResponsing) && (
|
{(completionRes || isResponding) && (
|
||||||
<TextGeneration
|
<TextGeneration
|
||||||
className="mt-2"
|
className="mt-2"
|
||||||
content={completionRes}
|
content={completionRes}
|
||||||
isLoading={!completionRes && isResponsing}
|
isLoading={!completionRes && isResponding}
|
||||||
isShowTextToSpeech={textToSpeechConfig.enabled && !!text2speechDefaultModel}
|
isShowTextToSpeech={textToSpeechConfig.enabled && !!text2speechDefaultModel}
|
||||||
isResponsing={isResponsing}
|
isResponding={isResponding}
|
||||||
isInstalledApp={false}
|
isInstalledApp={false}
|
||||||
messageId={messageId}
|
messageId={messageId}
|
||||||
isError={false}
|
isError={false}
|
||||||
|
@ -32,7 +32,7 @@ export type IGenerationItemProps = {
|
|||||||
messageId?: string | null
|
messageId?: string | null
|
||||||
conversationId?: string
|
conversationId?: string
|
||||||
isLoading?: boolean
|
isLoading?: boolean
|
||||||
isResponsing?: boolean
|
isResponding?: boolean
|
||||||
isInWebApp?: boolean
|
isInWebApp?: boolean
|
||||||
moreLikeThis?: boolean
|
moreLikeThis?: boolean
|
||||||
depth?: number
|
depth?: number
|
||||||
@ -81,7 +81,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
|
|||||||
content,
|
content,
|
||||||
messageId,
|
messageId,
|
||||||
isLoading,
|
isLoading,
|
||||||
isResponsing,
|
isResponding,
|
||||||
moreLikeThis,
|
moreLikeThis,
|
||||||
isInWebApp = false,
|
isInWebApp = false,
|
||||||
feedback,
|
feedback,
|
||||||
@ -277,7 +277,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
|
|||||||
<div className='flex items-center justify-between mt-3'>
|
<div className='flex items-center justify-between mt-3'>
|
||||||
<div className='flex items-center'>
|
<div className='flex items-center'>
|
||||||
{
|
{
|
||||||
!isInWebApp && !isInstalledApp && !isResponsing && (
|
!isInWebApp && !isInstalledApp && !isResponding && (
|
||||||
<PromptLog
|
<PromptLog
|
||||||
log={promptLog}
|
log={promptLog}
|
||||||
containerRef={ref}
|
containerRef={ref}
|
||||||
|
@ -43,7 +43,7 @@ const ChatWrapper = () => {
|
|||||||
chatList,
|
chatList,
|
||||||
handleSend,
|
handleSend,
|
||||||
handleStop,
|
handleStop,
|
||||||
isResponsing,
|
isResponding,
|
||||||
suggestedQuestions,
|
suggestedQuestions,
|
||||||
} = useChat(
|
} = useChat(
|
||||||
appConfig,
|
appConfig,
|
||||||
@ -130,7 +130,7 @@ const ChatWrapper = () => {
|
|||||||
<Chat
|
<Chat
|
||||||
config={appConfig}
|
config={appConfig}
|
||||||
chatList={chatList}
|
chatList={chatList}
|
||||||
isResponsing={isResponsing}
|
isResponding={isResponding}
|
||||||
chatContainerInnerClassName={`mx-auto pt-6 w-full max-w-[720px] ${isMobile && 'px-4'}`}
|
chatContainerInnerClassName={`mx-auto pt-6 w-full max-w-[720px] ${isMobile && 'px-4'}`}
|
||||||
chatFooterClassName='pb-4'
|
chatFooterClassName='pb-4'
|
||||||
chatFooterInnerClassName={`mx-auto w-full max-w-[720px] ${isMobile && 'px-4'}`}
|
chatFooterInnerClassName={`mx-auto w-full max-w-[720px] ${isMobile && 'px-4'}`}
|
||||||
|
@ -11,12 +11,12 @@ import type { Emoji } from '@/app/components/tools/types'
|
|||||||
|
|
||||||
type AgentContentProps = {
|
type AgentContentProps = {
|
||||||
item: ChatItem
|
item: ChatItem
|
||||||
responsing?: boolean
|
responding?: boolean
|
||||||
allToolIcons?: Record<string, string | Emoji>
|
allToolIcons?: Record<string, string | Emoji>
|
||||||
}
|
}
|
||||||
const AgentContent: FC<AgentContentProps> = ({
|
const AgentContent: FC<AgentContentProps> = ({
|
||||||
item,
|
item,
|
||||||
responsing,
|
responding,
|
||||||
allToolIcons,
|
allToolIcons,
|
||||||
}) => {
|
}) => {
|
||||||
const {
|
const {
|
||||||
@ -46,7 +46,7 @@ const AgentContent: FC<AgentContentProps> = ({
|
|||||||
<Thought
|
<Thought
|
||||||
thought={thought}
|
thought={thought}
|
||||||
allToolIcons={allToolIcons || {}}
|
allToolIcons={allToolIcons || {}}
|
||||||
isFinished={!!thought.observation || !responsing}
|
isFinished={!!thought.observation || !responding}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ type AnswerProps = {
|
|||||||
index: number
|
index: number
|
||||||
config?: ChatConfig
|
config?: ChatConfig
|
||||||
answerIcon?: ReactNode
|
answerIcon?: ReactNode
|
||||||
responsing?: boolean
|
responding?: boolean
|
||||||
allToolIcons?: Record<string, string | Emoji>
|
allToolIcons?: Record<string, string | Emoji>
|
||||||
}
|
}
|
||||||
const Answer: FC<AnswerProps> = ({
|
const Answer: FC<AnswerProps> = ({
|
||||||
@ -34,7 +34,7 @@ const Answer: FC<AnswerProps> = ({
|
|||||||
index,
|
index,
|
||||||
config,
|
config,
|
||||||
answerIcon,
|
answerIcon,
|
||||||
responsing,
|
responding,
|
||||||
allToolIcons,
|
allToolIcons,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@ -58,7 +58,7 @@ const Answer: FC<AnswerProps> = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
responsing && (
|
responding && (
|
||||||
<div className='absolute -top-[3px] -left-[3px] pl-[6px] flex items-center w-4 h-4 bg-white rounded-full shadow-xs border-[0.5px] border-gray-50'>
|
<div className='absolute -top-[3px] -left-[3px] pl-[6px] flex items-center w-4 h-4 bg-white rounded-full shadow-xs border-[0.5px] border-gray-50'>
|
||||||
<LoadingAnim type='avatar' />
|
<LoadingAnim type='avatar' />
|
||||||
</div>
|
</div>
|
||||||
@ -70,7 +70,7 @@ const Answer: FC<AnswerProps> = ({
|
|||||||
<AnswerTriangle className='absolute -left-2 top-0 w-2 h-3 text-gray-100' />
|
<AnswerTriangle className='absolute -left-2 top-0 w-2 h-3 text-gray-100' />
|
||||||
<div className='group relative inline-block px-4 py-3 max-w-full bg-gray-100 rounded-b-2xl rounded-tr-2xl text-sm text-gray-900'>
|
<div className='group relative inline-block px-4 py-3 max-w-full bg-gray-100 rounded-b-2xl rounded-tr-2xl text-sm text-gray-900'>
|
||||||
{
|
{
|
||||||
!responsing && (
|
!responding && (
|
||||||
<Operation
|
<Operation
|
||||||
item={item}
|
item={item}
|
||||||
question={question}
|
question={question}
|
||||||
@ -79,7 +79,7 @@ const Answer: FC<AnswerProps> = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
responsing && !content && !hasAgentThoughts && (
|
responding && !content && !hasAgentThoughts && (
|
||||||
<div className='flex items-center justify-center w-6 h-5'>
|
<div className='flex items-center justify-center w-6 h-5'>
|
||||||
<LoadingAnim type='text' />
|
<LoadingAnim type='text' />
|
||||||
</div>
|
</div>
|
||||||
@ -94,7 +94,7 @@ const Answer: FC<AnswerProps> = ({
|
|||||||
hasAgentThoughts && (
|
hasAgentThoughts && (
|
||||||
<AgentContent
|
<AgentContent
|
||||||
item={item}
|
item={item}
|
||||||
responsing={responsing}
|
responding={responding}
|
||||||
allToolIcons={allToolIcons}
|
allToolIcons={allToolIcons}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
@ -109,7 +109,7 @@ const Answer: FC<AnswerProps> = ({
|
|||||||
}
|
}
|
||||||
<SuggestedQuestions item={item} />
|
<SuggestedQuestions item={item} />
|
||||||
{
|
{
|
||||||
!!citation?.length && config?.retriever_resource?.enabled && !responsing && (
|
!!citation?.length && config?.retriever_resource?.enabled && !responding && (
|
||||||
<Citation data={citation} showHitInfo={config.supportCitationHitInfo} />
|
<Citation data={citation} showHitInfo={config.supportCitationHitInfo} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import { createContext, useContext } from 'use-context-selector'
|
|||||||
import type { ChatProps } from './index'
|
import type { ChatProps } from './index'
|
||||||
|
|
||||||
export type ChatContextValue = Pick<ChatProps, 'config'
|
export type ChatContextValue = Pick<ChatProps, 'config'
|
||||||
| 'isResponsing'
|
| 'isResponding'
|
||||||
| 'chatList'
|
| 'chatList'
|
||||||
| 'showPromptLog'
|
| 'showPromptLog'
|
||||||
| 'questionIcon'
|
| 'questionIcon'
|
||||||
@ -29,7 +29,7 @@ type ChatContextProviderProps = {
|
|||||||
export const ChatContextProvider = ({
|
export const ChatContextProvider = ({
|
||||||
children,
|
children,
|
||||||
config,
|
config,
|
||||||
isResponsing,
|
isResponding,
|
||||||
chatList,
|
chatList,
|
||||||
showPromptLog,
|
showPromptLog,
|
||||||
questionIcon,
|
questionIcon,
|
||||||
@ -44,7 +44,7 @@ export const ChatContextProvider = ({
|
|||||||
return (
|
return (
|
||||||
<ChatContext.Provider value={{
|
<ChatContext.Provider value={{
|
||||||
config,
|
config,
|
||||||
isResponsing,
|
isResponding,
|
||||||
chatList: chatList || [],
|
chatList: chatList || [],
|
||||||
showPromptLog,
|
showPromptLog,
|
||||||
questionIcon,
|
questionIcon,
|
||||||
|
@ -80,8 +80,8 @@ export const useChat = (
|
|||||||
const { notify } = useToastContext()
|
const { notify } = useToastContext()
|
||||||
const connversationId = useRef('')
|
const connversationId = useRef('')
|
||||||
const hasStopResponded = useRef(false)
|
const hasStopResponded = useRef(false)
|
||||||
const [isResponsing, setIsResponsing] = useState(false)
|
const [isResponding, setIsResponding] = useState(false)
|
||||||
const isResponsingRef = useRef(false)
|
const isRespondingRef = useRef(false)
|
||||||
const [chatList, setChatList] = useState<ChatItem[]>(prevChatList || [])
|
const [chatList, setChatList] = useState<ChatItem[]>(prevChatList || [])
|
||||||
const chatListRef = useRef<ChatItem[]>(prevChatList || [])
|
const chatListRef = useRef<ChatItem[]>(prevChatList || [])
|
||||||
const taskIdRef = useRef('')
|
const taskIdRef = useRef('')
|
||||||
@ -101,9 +101,9 @@ export const useChat = (
|
|||||||
setChatList(newChatList)
|
setChatList(newChatList)
|
||||||
chatListRef.current = newChatList
|
chatListRef.current = newChatList
|
||||||
}, [])
|
}, [])
|
||||||
const handleResponsing = useCallback((isResponsing: boolean) => {
|
const handleResponding = useCallback((isResponding: boolean) => {
|
||||||
setIsResponsing(isResponsing)
|
setIsResponding(isResponding)
|
||||||
isResponsingRef.current = isResponsing
|
isRespondingRef.current = isResponding
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const getIntroduction = useCallback((str: string) => {
|
const getIntroduction = useCallback((str: string) => {
|
||||||
@ -136,14 +136,14 @@ export const useChat = (
|
|||||||
|
|
||||||
const handleStop = useCallback(() => {
|
const handleStop = useCallback(() => {
|
||||||
hasStopResponded.current = true
|
hasStopResponded.current = true
|
||||||
handleResponsing(false)
|
handleResponding(false)
|
||||||
if (stopChat && taskIdRef.current)
|
if (stopChat && taskIdRef.current)
|
||||||
stopChat(taskIdRef.current)
|
stopChat(taskIdRef.current)
|
||||||
if (conversationMessagesAbortControllerRef.current)
|
if (conversationMessagesAbortControllerRef.current)
|
||||||
conversationMessagesAbortControllerRef.current.abort()
|
conversationMessagesAbortControllerRef.current.abort()
|
||||||
if (suggestedQuestionsAbortControllerRef.current)
|
if (suggestedQuestionsAbortControllerRef.current)
|
||||||
suggestedQuestionsAbortControllerRef.current.abort()
|
suggestedQuestionsAbortControllerRef.current.abort()
|
||||||
}, [stopChat, handleResponsing])
|
}, [stopChat, handleResponding])
|
||||||
|
|
||||||
const handleRestart = useCallback(() => {
|
const handleRestart = useCallback(() => {
|
||||||
connversationId.current = ''
|
connversationId.current = ''
|
||||||
@ -200,7 +200,7 @@ export const useChat = (
|
|||||||
) => {
|
) => {
|
||||||
setSuggestQuestions([])
|
setSuggestQuestions([])
|
||||||
|
|
||||||
if (isResponsingRef.current) {
|
if (isRespondingRef.current) {
|
||||||
notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') })
|
notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') })
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -235,7 +235,7 @@ export const useChat = (
|
|||||||
isAnswer: true,
|
isAnswer: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
handleResponsing(true)
|
handleResponding(true)
|
||||||
hasStopResponded.current = false
|
hasStopResponded.current = false
|
||||||
|
|
||||||
const bodyParams = {
|
const bodyParams = {
|
||||||
@ -295,7 +295,7 @@ export const useChat = (
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
async onCompleted(hasError?: boolean) {
|
async onCompleted(hasError?: boolean) {
|
||||||
handleResponsing(false)
|
handleResponding(false)
|
||||||
|
|
||||||
if (hasError)
|
if (hasError)
|
||||||
return
|
return
|
||||||
@ -416,7 +416,7 @@ export const useChat = (
|
|||||||
responseItem.content = messageReplace.answer
|
responseItem.content = messageReplace.answer
|
||||||
},
|
},
|
||||||
onError() {
|
onError() {
|
||||||
handleResponsing(false)
|
handleResponding(false)
|
||||||
const newChatList = produce(chatListRef.current, (draft) => {
|
const newChatList = produce(chatListRef.current, (draft) => {
|
||||||
draft.splice(draft.findIndex(item => item.id === placeholderAnswerId), 1)
|
draft.splice(draft.findIndex(item => item.id === placeholderAnswerId), 1)
|
||||||
})
|
})
|
||||||
@ -432,7 +432,7 @@ export const useChat = (
|
|||||||
notify,
|
notify,
|
||||||
promptVariablesConfig,
|
promptVariablesConfig,
|
||||||
handleUpdateChatList,
|
handleUpdateChatList,
|
||||||
handleResponsing,
|
handleResponding,
|
||||||
])
|
])
|
||||||
|
|
||||||
const handleAnnotationEdited = useCallback((query: string, answer: string, index: number) => {
|
const handleAnnotationEdited = useCallback((query: string, answer: string, index: number) => {
|
||||||
@ -506,8 +506,8 @@ export const useChat = (
|
|||||||
chatList,
|
chatList,
|
||||||
setChatList,
|
setChatList,
|
||||||
conversationId: connversationId.current,
|
conversationId: connversationId.current,
|
||||||
isResponsing,
|
isResponding,
|
||||||
setIsResponsing,
|
setIsResponding,
|
||||||
handleSend,
|
handleSend,
|
||||||
suggestedQuestions,
|
suggestedQuestions,
|
||||||
handleRestart,
|
handleRestart,
|
||||||
|
@ -28,7 +28,7 @@ import { StopCircle } from '@/app/components/base/icons/src/vender/solid/mediaAn
|
|||||||
export type ChatProps = {
|
export type ChatProps = {
|
||||||
chatList: ChatItem[]
|
chatList: ChatItem[]
|
||||||
config?: ChatConfig
|
config?: ChatConfig
|
||||||
isResponsing?: boolean
|
isResponding?: boolean
|
||||||
noStopResponding?: boolean
|
noStopResponding?: boolean
|
||||||
onStopResponding?: () => void
|
onStopResponding?: () => void
|
||||||
noChatInput?: boolean
|
noChatInput?: boolean
|
||||||
@ -52,7 +52,7 @@ const Chat: FC<ChatProps> = ({
|
|||||||
config,
|
config,
|
||||||
onSend,
|
onSend,
|
||||||
chatList,
|
chatList,
|
||||||
isResponsing,
|
isResponding,
|
||||||
noStopResponding,
|
noStopResponding,
|
||||||
onStopResponding,
|
onStopResponding,
|
||||||
noChatInput,
|
noChatInput,
|
||||||
@ -125,7 +125,7 @@ const Chat: FC<ChatProps> = ({
|
|||||||
<ChatContextProvider
|
<ChatContextProvider
|
||||||
config={config}
|
config={config}
|
||||||
chatList={chatList}
|
chatList={chatList}
|
||||||
isResponsing={isResponsing}
|
isResponding={isResponding}
|
||||||
showPromptLog={showPromptLog}
|
showPromptLog={showPromptLog}
|
||||||
questionIcon={questionIcon}
|
questionIcon={questionIcon}
|
||||||
answerIcon={answerIcon}
|
answerIcon={answerIcon}
|
||||||
@ -158,7 +158,7 @@ const Chat: FC<ChatProps> = ({
|
|||||||
index={index}
|
index={index}
|
||||||
config={config}
|
config={config}
|
||||||
answerIcon={answerIcon}
|
answerIcon={answerIcon}
|
||||||
responsing={isLast && isResponsing}
|
responding={isLast && isResponding}
|
||||||
allToolIcons={allToolIcons}
|
allToolIcons={allToolIcons}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
@ -169,7 +169,7 @@ const Chat: FC<ChatProps> = ({
|
|||||||
item={item}
|
item={item}
|
||||||
showPromptLog={showPromptLog}
|
showPromptLog={showPromptLog}
|
||||||
questionIcon={questionIcon}
|
questionIcon={questionIcon}
|
||||||
isResponsing={isResponsing}
|
isResponding={isResponding}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -188,7 +188,7 @@ const Chat: FC<ChatProps> = ({
|
|||||||
className={`${chatFooterInnerClassName}`}
|
className={`${chatFooterInnerClassName}`}
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
!noStopResponding && isResponsing && (
|
!noStopResponding && isResponding && (
|
||||||
<div className='flex justify-center mb-2'>
|
<div className='flex justify-center mb-2'>
|
||||||
<Button className='py-0 px-3 h-7 bg-white shadow-xs' onClick={onStopResponding}>
|
<Button className='py-0 px-3 h-7 bg-white shadow-xs' onClick={onStopResponding}>
|
||||||
<StopCircle className='mr-[5px] w-3.5 h-3.5 text-gray-500' />
|
<StopCircle className='mr-[5px] w-3.5 h-3.5 text-gray-500' />
|
||||||
|
@ -17,12 +17,12 @@ type QuestionProps = {
|
|||||||
item: ChatItem
|
item: ChatItem
|
||||||
showPromptLog?: boolean
|
showPromptLog?: boolean
|
||||||
questionIcon?: ReactNode
|
questionIcon?: ReactNode
|
||||||
isResponsing?: boolean
|
isResponding?: boolean
|
||||||
}
|
}
|
||||||
const Question: FC<QuestionProps> = ({
|
const Question: FC<QuestionProps> = ({
|
||||||
item,
|
item,
|
||||||
showPromptLog,
|
showPromptLog,
|
||||||
isResponsing,
|
isResponding,
|
||||||
questionIcon,
|
questionIcon,
|
||||||
}) => {
|
}) => {
|
||||||
const ref = useRef(null)
|
const ref = useRef(null)
|
||||||
@ -38,7 +38,7 @@ const Question: FC<QuestionProps> = ({
|
|||||||
<div className='group relative mr-4'>
|
<div className='group relative mr-4'>
|
||||||
<QuestionTriangle className='absolute -right-2 top-0 w-2 h-3 text-[#D1E9FF]/50' />
|
<QuestionTriangle className='absolute -right-2 top-0 w-2 h-3 text-[#D1E9FF]/50' />
|
||||||
{
|
{
|
||||||
showPromptLog && !isResponsing && (
|
showPromptLog && !isResponding && (
|
||||||
<Log log={item.log!} containerRef={ref} />
|
<Log log={item.log!} containerRef={ref} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import { ssePost } from '@/service/base'
|
|||||||
export const useTextGeneration = () => {
|
export const useTextGeneration = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { notify } = useToastContext()
|
const { notify } = useToastContext()
|
||||||
const [isResponsing, setIsResponsing] = useState(false)
|
const [isResponding, setIsResponding] = useState(false)
|
||||||
const [completion, setCompletion] = useState('')
|
const [completion, setCompletion] = useState('')
|
||||||
const [messageId, setMessageId] = useState<string | null>(null)
|
const [messageId, setMessageId] = useState<string | null>(null)
|
||||||
|
|
||||||
@ -14,12 +14,12 @@ export const useTextGeneration = () => {
|
|||||||
url: string,
|
url: string,
|
||||||
data: any,
|
data: any,
|
||||||
) => {
|
) => {
|
||||||
if (isResponsing) {
|
if (isResponding) {
|
||||||
notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') })
|
notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') })
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsResponsing(true)
|
setIsResponding(true)
|
||||||
setCompletion('')
|
setCompletion('')
|
||||||
setMessageId('')
|
setMessageId('')
|
||||||
let res: string[] = []
|
let res: string[] = []
|
||||||
@ -42,10 +42,10 @@ export const useTextGeneration = () => {
|
|||||||
setCompletion(res.join(''))
|
setCompletion(res.join(''))
|
||||||
},
|
},
|
||||||
onCompleted() {
|
onCompleted() {
|
||||||
setIsResponsing(false)
|
setIsResponding(false)
|
||||||
},
|
},
|
||||||
onError() {
|
onError() {
|
||||||
setIsResponsing(false)
|
setIsResponding(false)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
return true
|
return true
|
||||||
@ -53,8 +53,8 @@ export const useTextGeneration = () => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
completion,
|
completion,
|
||||||
isResponsing,
|
isResponding,
|
||||||
setIsResponsing,
|
setIsResponding,
|
||||||
handleSend,
|
handleSend,
|
||||||
messageId,
|
messageId,
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
const [citationConfig, setCitationConfig] = useState<CitationConfig | null>(null)
|
const [citationConfig, setCitationConfig] = useState<CitationConfig | null>(null)
|
||||||
const [chatList, setChatList, getChatList] = useGetState<IChatItem[]>([])
|
const [chatList, setChatList, getChatList] = useGetState<IChatItem[]>([])
|
||||||
const chatListDomRef = useRef<HTMLDivElement>(null)
|
const chatListDomRef = useRef<HTMLDivElement>(null)
|
||||||
const [isResponsing, { setTrue: setResponsingTrue, setFalse: setResponsingFalse }] = useBoolean(false)
|
const [isResponding, { setTrue: setRespondingTrue, setFalse: setRespondingFalse }] = useBoolean(false)
|
||||||
const [abortController, setAbortController] = useState<AbortController | null>(null)
|
const [abortController, setAbortController] = useState<AbortController | null>(null)
|
||||||
const [conversationIdChangeBecauseOfNew, setConversationIdChangeBecauseOfNew, getConversationIdChangeBecauseOfNew] = useGetState(false)
|
const [conversationIdChangeBecauseOfNew, setConversationIdChangeBecauseOfNew, getConversationIdChangeBecauseOfNew] = useGetState(false)
|
||||||
const [isChatStarted, { setTrue: setChatStarted, setFalse: setChatNotStarted }] = useBoolean(false)
|
const [isChatStarted, { setTrue: setChatStarted, setFalse: setChatNotStarted }] = useBoolean(false)
|
||||||
@ -198,7 +198,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
const createNewChat = useCallback(async () => {
|
const createNewChat = useCallback(async () => {
|
||||||
// if new chat is already exist, do not create new chat
|
// if new chat is already exist, do not create new chat
|
||||||
abortController?.abort()
|
abortController?.abort()
|
||||||
setResponsingFalse()
|
setRespondingFalse()
|
||||||
if (conversationList.some(item => item.id === '-1'))
|
if (conversationList.some(item => item.id === '-1'))
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
}))
|
}))
|
||||||
}, [
|
}, [
|
||||||
abortController,
|
abortController,
|
||||||
setResponsingFalse,
|
setRespondingFalse,
|
||||||
setConversationList,
|
setConversationList,
|
||||||
conversationList,
|
conversationList,
|
||||||
newConversationInputs,
|
newConversationInputs,
|
||||||
@ -504,11 +504,11 @@ const Main: FC<IMainProps> = ({
|
|||||||
}, [currConversationId, currInputs, promptConfig, t, logError])
|
}, [currConversationId, currInputs, promptConfig, t, logError])
|
||||||
|
|
||||||
const [controlFocus, setControlFocus] = useState(0)
|
const [controlFocus, setControlFocus] = useState(0)
|
||||||
const doShowSuggestion = isShowSuggestion && !isResponsing
|
const doShowSuggestion = isShowSuggestion && !isResponding
|
||||||
const [openingSuggestedQuestions, setOpeningSuggestedQuestions] = useState<string[]>([])
|
const [openingSuggestedQuestions, setOpeningSuggestedQuestions] = useState<string[]>([])
|
||||||
const [messageTaskId, setMessageTaskId] = useState('')
|
const [messageTaskId, setMessageTaskId] = useState('')
|
||||||
const [hasStopResponded, setHasStopResponded, getHasStopResponded] = useGetState(false)
|
const [hasStopResponded, setHasStopResponded, getHasStopResponded] = useGetState(false)
|
||||||
const [isResponsingConIsCurrCon, setIsResponsingConCurrCon, getIsResponsingConIsCurrCon] = useGetState(true)
|
const [isRespondingConIsCurrCon, setIsRespondingConCurrCon, getIsRespondingConIsCurrCon] = useGetState(true)
|
||||||
const [userQuery, setUserQuery] = useState('')
|
const [userQuery, setUserQuery] = useState('')
|
||||||
const [visionConfig, setVisionConfig] = useState<VisionSettings>({
|
const [visionConfig, setVisionConfig] = useState<VisionSettings>({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
@ -541,7 +541,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleSend = async (message: string, files?: VisionFile[]) => {
|
const handleSend = async (message: string, files?: VisionFile[]) => {
|
||||||
if (isResponsing) {
|
if (isResponding) {
|
||||||
notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') })
|
notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -605,9 +605,9 @@ const Main: FC<IMainProps> = ({
|
|||||||
let tempNewConversationId = prevTempNewConversationId
|
let tempNewConversationId = prevTempNewConversationId
|
||||||
|
|
||||||
setHasStopResponded(false)
|
setHasStopResponded(false)
|
||||||
setResponsingTrue()
|
setRespondingTrue()
|
||||||
setIsShowSuggestion(false)
|
setIsShowSuggestion(false)
|
||||||
setIsResponsingConCurrCon(true)
|
setIsRespondingConCurrCon(true)
|
||||||
sendChatMessage(data, {
|
sendChatMessage(data, {
|
||||||
getAbortController: (abortController) => {
|
getAbortController: (abortController) => {
|
||||||
setAbortController(abortController)
|
setAbortController(abortController)
|
||||||
@ -632,7 +632,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
setMessageTaskId(taskId)
|
setMessageTaskId(taskId)
|
||||||
// has switched to other conversation
|
// has switched to other conversation
|
||||||
if (prevTempNewConversationId !== getCurrConversationId()) {
|
if (prevTempNewConversationId !== getCurrConversationId()) {
|
||||||
setIsResponsingConCurrCon(false)
|
setIsRespondingConCurrCon(false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
updateCurrentQA({
|
updateCurrentQA({
|
||||||
@ -660,12 +660,12 @@ const Main: FC<IMainProps> = ({
|
|||||||
resetNewConversationInputs()
|
resetNewConversationInputs()
|
||||||
setChatNotStarted()
|
setChatNotStarted()
|
||||||
setCurrConversationId(tempNewConversationId, appId, true)
|
setCurrConversationId(tempNewConversationId, appId, true)
|
||||||
if (getIsResponsingConIsCurrCon() && suggestedQuestionsAfterAnswerConfig?.enabled && !getHasStopResponded()) {
|
if (getIsRespondingConIsCurrCon() && suggestedQuestionsAfterAnswerConfig?.enabled && !getHasStopResponded()) {
|
||||||
const { data }: any = await fetchSuggestedQuestions(responseItem.id, isInstalledApp, installedAppInfo?.id)
|
const { data }: any = await fetchSuggestedQuestions(responseItem.id, isInstalledApp, installedAppInfo?.id)
|
||||||
setSuggestQuestions(data)
|
setSuggestQuestions(data)
|
||||||
setIsShowSuggestion(true)
|
setIsShowSuggestion(true)
|
||||||
}
|
}
|
||||||
setResponsingFalse()
|
setRespondingFalse()
|
||||||
},
|
},
|
||||||
onFile(file) {
|
onFile(file) {
|
||||||
const lastThought = responseItem.agent_thoughts?.[responseItem.agent_thoughts?.length - 1]
|
const lastThought = responseItem.agent_thoughts?.[responseItem.agent_thoughts?.length - 1]
|
||||||
@ -704,7 +704,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
}
|
}
|
||||||
// has switched to other conversation
|
// has switched to other conversation
|
||||||
if (prevTempNewConversationId !== getCurrConversationId()) {
|
if (prevTempNewConversationId !== getCurrConversationId()) {
|
||||||
setIsResponsingConCurrCon(false)
|
setIsRespondingConCurrCon(false)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -766,7 +766,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError() {
|
onError() {
|
||||||
setResponsingFalse()
|
setRespondingFalse()
|
||||||
// role back placeholder answer
|
// role back placeholder answer
|
||||||
setChatList(produce(getChatList(), (draft) => {
|
setChatList(produce(getChatList(), (draft) => {
|
||||||
draft.splice(draft.findIndex(item => item.id === placeholderAnswerId), 1)
|
draft.splice(draft.findIndex(item => item.id === placeholderAnswerId), 1)
|
||||||
@ -832,10 +832,10 @@ const Main: FC<IMainProps> = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleAbortResponsing = useCallback(async () => {
|
const handleAbortResponding = useCallback(async () => {
|
||||||
await stopChatMessageResponding(appId, messageTaskId, isInstalledApp, installedAppInfo?.id)
|
await stopChatMessageResponding(appId, messageTaskId, isInstalledApp, installedAppInfo?.id)
|
||||||
setHasStopResponded(true)
|
setHasStopResponded(true)
|
||||||
setResponsingFalse()
|
setRespondingFalse()
|
||||||
}, [appId, messageTaskId, isInstalledApp, installedAppInfo?.id])
|
}, [appId, messageTaskId, isInstalledApp, installedAppInfo?.id])
|
||||||
|
|
||||||
if (appUnavailable)
|
if (appUnavailable)
|
||||||
@ -905,7 +905,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
|
|
||||||
{
|
{
|
||||||
hasSetInputs && (
|
hasSetInputs && (
|
||||||
<div className={cn(doShowSuggestion ? 'pb-[140px]' : (isResponsing ? 'pb-[113px]' : 'pb-[76px]'), 'relative grow h-[200px] pc:w-[794px] max-w-full mobile:w-full mx-auto mb-3.5 overflow-hidden')}>
|
<div className={cn(doShowSuggestion ? 'pb-[140px]' : (isResponding ? 'pb-[113px]' : 'pb-[76px]'), 'relative grow h-[200px] pc:w-[794px] max-w-full mobile:w-full mx-auto mb-3.5 overflow-hidden')}>
|
||||||
<div className='h-full overflow-y-auto' ref={chatListDomRef}>
|
<div className='h-full overflow-y-auto' ref={chatListDomRef}>
|
||||||
<Chat
|
<Chat
|
||||||
chatList={chatList}
|
chatList={chatList}
|
||||||
@ -914,9 +914,9 @@ const Main: FC<IMainProps> = ({
|
|||||||
onSend={handleSend}
|
onSend={handleSend}
|
||||||
isHideFeedbackEdit
|
isHideFeedbackEdit
|
||||||
onFeedback={handleFeedback}
|
onFeedback={handleFeedback}
|
||||||
isResponsing={isResponsing}
|
isResponding={isResponding}
|
||||||
canStopResponsing={!!messageTaskId && isResponsingConIsCurrCon}
|
canStopResponding={!!messageTaskId && isRespondingConIsCurrCon}
|
||||||
abortResponsing={handleAbortResponsing}
|
abortResponding={handleAbortResponding}
|
||||||
checkCanSend={checkCanSend}
|
checkCanSend={checkCanSend}
|
||||||
controlFocus={controlFocus}
|
controlFocus={controlFocus}
|
||||||
isShowSuggestion={doShowSuggestion}
|
isShowSuggestion={doShowSuggestion}
|
||||||
|
@ -203,7 +203,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update chat list of current conversation
|
// update chat list of current conversation
|
||||||
if (!isNewConversation && !conversationIdChangeBecauseOfNew && !isResponsing) {
|
if (!isNewConversation && !conversationIdChangeBecauseOfNew && !isResponding) {
|
||||||
fetchChatList(currConversationId, isInstalledApp, installedAppInfo?.id).then((res: any) => {
|
fetchChatList(currConversationId, isInstalledApp, installedAppInfo?.id).then((res: any) => {
|
||||||
const { data } = res
|
const { data } = res
|
||||||
const newChatList: IChatItem[] = generateNewChatListWithOpenstatement(notSyncToStateIntroduction, notSyncToStateInputs)
|
const newChatList: IChatItem[] = generateNewChatListWithOpenstatement(notSyncToStateIntroduction, notSyncToStateInputs)
|
||||||
@ -252,7 +252,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
const createNewChat = async () => {
|
const createNewChat = async () => {
|
||||||
// if new chat is already exist, do not create new chat
|
// if new chat is already exist, do not create new chat
|
||||||
abortController?.abort()
|
abortController?.abort()
|
||||||
setResponsingFalse()
|
setRespondingFalse()
|
||||||
if (conversationList.some(item => item.id === '-1'))
|
if (conversationList.some(item => item.id === '-1'))
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -369,7 +369,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
})()
|
})()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const [isResponsing, { setTrue: setResponsingTrue, setFalse: setResponsingFalse }] = useBoolean(false)
|
const [isResponding, { setTrue: setRespondingTrue, setFalse: setRespondingFalse }] = useBoolean(false)
|
||||||
const [abortController, setAbortController] = useState<AbortController | null>(null)
|
const [abortController, setAbortController] = useState<AbortController | null>(null)
|
||||||
const { notify } = useContext(ToastContext)
|
const { notify } = useContext(ToastContext)
|
||||||
const logError = (message: string) => {
|
const logError = (message: string) => {
|
||||||
@ -407,11 +407,11 @@ const Main: FC<IMainProps> = ({
|
|||||||
|
|
||||||
const [controlFocus, setControlFocus] = useState(0)
|
const [controlFocus, setControlFocus] = useState(0)
|
||||||
const [isShowSuggestion, setIsShowSuggestion] = useState(false)
|
const [isShowSuggestion, setIsShowSuggestion] = useState(false)
|
||||||
const doShowSuggestion = isShowSuggestion && !isResponsing
|
const doShowSuggestion = isShowSuggestion && !isResponding
|
||||||
const [suggestQuestions, setSuggestQuestions] = useState<string[]>([])
|
const [suggestQuestions, setSuggestQuestions] = useState<string[]>([])
|
||||||
const [messageTaskId, setMessageTaskId] = useState('')
|
const [messageTaskId, setMessageTaskId] = useState('')
|
||||||
const [hasStopResponded, setHasStopResponded, getHasStopResponded] = useGetState(false)
|
const [hasStopResponded, setHasStopResponded, getHasStopResponded] = useGetState(false)
|
||||||
const [isResponsingConIsCurrCon, setIsResponsingConCurrCon, getIsResponsingConIsCurrCon] = useGetState(true)
|
const [isRespondingConIsCurrCon, setIsRespondingConCurrCon, getIsRespondingConIsCurrCon] = useGetState(true)
|
||||||
const [shouldReload, setShouldReload] = useState(false)
|
const [shouldReload, setShouldReload] = useState(false)
|
||||||
const [userQuery, setUserQuery] = useState('')
|
const [userQuery, setUserQuery] = useState('')
|
||||||
const [visionConfig, setVisionConfig] = useState<VisionSettings>({
|
const [visionConfig, setVisionConfig] = useState<VisionSettings>({
|
||||||
@ -445,7 +445,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleSend = async (message: string, files?: VisionFile[]) => {
|
const handleSend = async (message: string, files?: VisionFile[]) => {
|
||||||
if (isResponsing) {
|
if (isResponding) {
|
||||||
notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') })
|
notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -507,7 +507,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
let tempNewConversationId = prevTempNewConversationId
|
let tempNewConversationId = prevTempNewConversationId
|
||||||
|
|
||||||
setHasStopResponded(false)
|
setHasStopResponded(false)
|
||||||
setResponsingTrue()
|
setRespondingTrue()
|
||||||
setIsShowSuggestion(false)
|
setIsShowSuggestion(false)
|
||||||
sendChatMessage(data, {
|
sendChatMessage(data, {
|
||||||
getAbortController: (abortController) => {
|
getAbortController: (abortController) => {
|
||||||
@ -533,7 +533,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
setMessageTaskId(taskId)
|
setMessageTaskId(taskId)
|
||||||
// has switched to other conversation
|
// has switched to other conversation
|
||||||
if (prevTempNewConversationId !== getCurrConversationId()) {
|
if (prevTempNewConversationId !== getCurrConversationId()) {
|
||||||
setIsResponsingConCurrCon(false)
|
setIsRespondingConCurrCon(false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
updateCurrentQA({
|
updateCurrentQA({
|
||||||
@ -565,7 +565,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
setSuggestQuestions(data)
|
setSuggestQuestions(data)
|
||||||
setIsShowSuggestion(true)
|
setIsShowSuggestion(true)
|
||||||
}
|
}
|
||||||
setResponsingFalse()
|
setRespondingFalse()
|
||||||
},
|
},
|
||||||
onFile(file) {
|
onFile(file) {
|
||||||
const lastThought = responseItem.agent_thoughts?.[responseItem.agent_thoughts?.length - 1]
|
const lastThought = responseItem.agent_thoughts?.[responseItem.agent_thoughts?.length - 1]
|
||||||
@ -604,7 +604,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
}
|
}
|
||||||
// has switched to other conversation
|
// has switched to other conversation
|
||||||
if (prevTempNewConversationId !== getCurrConversationId()) {
|
if (prevTempNewConversationId !== getCurrConversationId()) {
|
||||||
setIsResponsingConCurrCon(false)
|
setIsRespondingConCurrCon(false)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,7 +666,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError() {
|
onError() {
|
||||||
setResponsingFalse()
|
setRespondingFalse()
|
||||||
// role back placeholder answer
|
// role back placeholder answer
|
||||||
setChatList(produce(getChatList(), (draft) => {
|
setChatList(produce(getChatList(), (draft) => {
|
||||||
draft.splice(draft.findIndex(item => item.id === placeholderAnswerId), 1)
|
draft.splice(draft.findIndex(item => item.id === placeholderAnswerId), 1)
|
||||||
@ -773,7 +773,7 @@ const Main: FC<IMainProps> = ({
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
hasSetInputs && (
|
hasSetInputs && (
|
||||||
<div className={cn(doShowSuggestion ? 'pb-[140px]' : (isResponsing ? 'pb-[113px]' : 'pb-[76px]'), 'relative grow h-[200px] pc:w-[794px] max-w-full mobile:w-full mx-auto mb-3.5 overflow-hidden')}>
|
<div className={cn(doShowSuggestion ? 'pb-[140px]' : (isResponding ? 'pb-[113px]' : 'pb-[76px]'), 'relative grow h-[200px] pc:w-[794px] max-w-full mobile:w-full mx-auto mb-3.5 overflow-hidden')}>
|
||||||
<div className='h-full overflow-y-auto' ref={chatListDomRef}>
|
<div className='h-full overflow-y-auto' ref={chatListDomRef}>
|
||||||
<Chat
|
<Chat
|
||||||
chatList={chatList}
|
chatList={chatList}
|
||||||
@ -782,12 +782,12 @@ const Main: FC<IMainProps> = ({
|
|||||||
onSend={handleSend}
|
onSend={handleSend}
|
||||||
isHideFeedbackEdit
|
isHideFeedbackEdit
|
||||||
onFeedback={handleFeedback}
|
onFeedback={handleFeedback}
|
||||||
isResponsing={isResponsing}
|
isResponding={isResponding}
|
||||||
canStopResponsing={!!messageTaskId && isResponsingConIsCurrCon}
|
canStopResponding={!!messageTaskId && isRespondingConIsCurrCon}
|
||||||
abortResponsing={async () => {
|
abortResponding={async () => {
|
||||||
await stopChatMessageResponding(appId, messageTaskId, isInstalledApp, installedAppInfo?.id)
|
await stopChatMessageResponding(appId, messageTaskId, isInstalledApp, installedAppInfo?.id)
|
||||||
setHasStopResponded(true)
|
setHasStopResponded(true)
|
||||||
setResponsingFalse()
|
setRespondingFalse()
|
||||||
}}
|
}}
|
||||||
checkCanSend={checkCanSend}
|
checkCanSend={checkCanSend}
|
||||||
controlFocus={controlFocus}
|
controlFocus={controlFocus}
|
||||||
|
@ -60,10 +60,10 @@ const Result: FC<IResultProps> = ({
|
|||||||
visionConfig,
|
visionConfig,
|
||||||
completionFiles,
|
completionFiles,
|
||||||
}) => {
|
}) => {
|
||||||
const [isResponsing, { setTrue: setResponsingTrue, setFalse: setResponsingFalse }] = useBoolean(false)
|
const [isResponding, { setTrue: setRespondingTrue, setFalse: setRespondingFalse }] = useBoolean(false)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (controlStopResponding)
|
if (controlStopResponding)
|
||||||
setResponsingFalse()
|
setRespondingFalse()
|
||||||
}, [controlStopResponding])
|
}, [controlStopResponding])
|
||||||
|
|
||||||
const [completionRes, doSetCompletionRes] = useState('')
|
const [completionRes, doSetCompletionRes] = useState('')
|
||||||
@ -130,7 +130,7 @@ const Result: FC<IResultProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleSend = async () => {
|
const handleSend = async () => {
|
||||||
if (isResponsing) {
|
if (isResponding) {
|
||||||
notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') })
|
notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') })
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -165,13 +165,13 @@ const Result: FC<IResultProps> = ({
|
|||||||
if (!isPC)
|
if (!isPC)
|
||||||
onShowRes()
|
onShowRes()
|
||||||
|
|
||||||
setResponsingTrue()
|
setRespondingTrue()
|
||||||
const startTime = Date.now()
|
const startTime = Date.now()
|
||||||
let isTimeout = false
|
let isTimeout = false
|
||||||
const runId = setInterval(() => {
|
const runId = setInterval(() => {
|
||||||
if (Date.now() - startTime > 1000 * 60) { // 1min timeout
|
if (Date.now() - startTime > 1000 * 60) { // 1min timeout
|
||||||
clearInterval(runId)
|
clearInterval(runId)
|
||||||
setResponsingFalse()
|
setRespondingFalse()
|
||||||
onCompleted(getCompletionRes(), taskId, false)
|
onCompleted(getCompletionRes(), taskId, false)
|
||||||
isTimeout = true
|
isTimeout = true
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ const Result: FC<IResultProps> = ({
|
|||||||
if (isTimeout)
|
if (isTimeout)
|
||||||
return
|
return
|
||||||
|
|
||||||
setResponsingFalse()
|
setRespondingFalse()
|
||||||
setMessageId(tempMessageId)
|
setMessageId(tempMessageId)
|
||||||
onCompleted(getCompletionRes(), taskId, true)
|
onCompleted(getCompletionRes(), taskId, true)
|
||||||
clearInterval(runId)
|
clearInterval(runId)
|
||||||
@ -199,7 +199,7 @@ const Result: FC<IResultProps> = ({
|
|||||||
if (isTimeout)
|
if (isTimeout)
|
||||||
return
|
return
|
||||||
|
|
||||||
setResponsingFalse()
|
setRespondingFalse()
|
||||||
onCompleted(getCompletionRes(), taskId, false)
|
onCompleted(getCompletionRes(), taskId, false)
|
||||||
clearInterval(runId)
|
clearInterval(runId)
|
||||||
},
|
},
|
||||||
@ -234,7 +234,7 @@ const Result: FC<IResultProps> = ({
|
|||||||
isMobile={isMobile}
|
isMobile={isMobile}
|
||||||
isInstalledApp={isInstalledApp}
|
isInstalledApp={isInstalledApp}
|
||||||
installedAppId={installedAppInfo?.id}
|
installedAppId={installedAppInfo?.id}
|
||||||
isLoading={isCallBatchAPI ? (!completionRes && isResponsing) : false}
|
isLoading={isCallBatchAPI ? (!completionRes && isResponding) : false}
|
||||||
taskId={isCallBatchAPI ? ((taskId as number) < 10 ? `0${taskId}` : `${taskId}`) : undefined}
|
taskId={isCallBatchAPI ? ((taskId as number) < 10 ? `0${taskId}` : `${taskId}`) : undefined}
|
||||||
controlClearMoreLikeThis={controlClearMoreLikeThis}
|
controlClearMoreLikeThis={controlClearMoreLikeThis}
|
||||||
isShowTextToSpeech={isShowTextToSpeech}
|
isShowTextToSpeech={isShowTextToSpeech}
|
||||||
@ -244,7 +244,7 @@ const Result: FC<IResultProps> = ({
|
|||||||
return (
|
return (
|
||||||
<div className={cn(isNoData && !isCallBatchAPI && 'h-full')}>
|
<div className={cn(isNoData && !isCallBatchAPI && 'h-full')}>
|
||||||
{!isCallBatchAPI && (
|
{!isCallBatchAPI && (
|
||||||
(isResponsing && !completionRes)
|
(isResponding && !completionRes)
|
||||||
? (
|
? (
|
||||||
<div className='flex h-full w-full justify-center items-center'>
|
<div className='flex h-full w-full justify-center items-center'>
|
||||||
<Loading type='area' />
|
<Loading type='area' />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user