fix typo: responsing -> responding (#2718)

Co-authored-by: OSS-MAOLONGDONG\kaihong <maolongdong@kaihong.com>
This commit is contained in:
Lance Mao
2024-03-07 10:20:35 +08:00
committed by GitHub
parent 31070ffbca
commit 7052565380
19 changed files with 127 additions and 127 deletions

View File

@@ -43,7 +43,7 @@ const ChatWrapper = () => {
chatList,
handleSend,
handleStop,
isResponsing,
isResponding,
suggestedQuestions,
} = useChat(
appConfig,
@@ -130,7 +130,7 @@ const ChatWrapper = () => {
<Chat
config={appConfig}
chatList={chatList}
isResponsing={isResponsing}
isResponding={isResponding}
chatContainerInnerClassName={`mx-auto pt-6 w-full max-w-[720px] ${isMobile && 'px-4'}`}
chatFooterClassName='pb-4'
chatFooterInnerClassName={`mx-auto w-full max-w-[720px] ${isMobile && 'px-4'}`}

View File

@@ -11,12 +11,12 @@ import type { Emoji } from '@/app/components/tools/types'
type AgentContentProps = {
item: ChatItem
responsing?: boolean
responding?: boolean
allToolIcons?: Record<string, string | Emoji>
}
const AgentContent: FC<AgentContentProps> = ({
item,
responsing,
responding,
allToolIcons,
}) => {
const {
@@ -46,7 +46,7 @@ const AgentContent: FC<AgentContentProps> = ({
<Thought
thought={thought}
allToolIcons={allToolIcons || {}}
isFinished={!!thought.observation || !responsing}
isFinished={!!thought.observation || !responding}
/>
)}

View File

@@ -25,7 +25,7 @@ type AnswerProps = {
index: number
config?: ChatConfig
answerIcon?: ReactNode
responsing?: boolean
responding?: boolean
allToolIcons?: Record<string, string | Emoji>
}
const Answer: FC<AnswerProps> = ({
@@ -34,7 +34,7 @@ const Answer: FC<AnswerProps> = ({
index,
config,
answerIcon,
responsing,
responding,
allToolIcons,
}) => {
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'>
<LoadingAnim type='avatar' />
</div>
@@ -70,7 +70,7 @@ const Answer: FC<AnswerProps> = ({
<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'>
{
!responsing && (
!responding && (
<Operation
item={item}
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'>
<LoadingAnim type='text' />
</div>
@@ -94,7 +94,7 @@ const Answer: FC<AnswerProps> = ({
hasAgentThoughts && (
<AgentContent
item={item}
responsing={responsing}
responding={responding}
allToolIcons={allToolIcons}
/>
)
@@ -109,7 +109,7 @@ const Answer: FC<AnswerProps> = ({
}
<SuggestedQuestions item={item} />
{
!!citation?.length && config?.retriever_resource?.enabled && !responsing && (
!!citation?.length && config?.retriever_resource?.enabled && !responding && (
<Citation data={citation} showHitInfo={config.supportCitationHitInfo} />
)
}

View File

@@ -5,7 +5,7 @@ import { createContext, useContext } from 'use-context-selector'
import type { ChatProps } from './index'
export type ChatContextValue = Pick<ChatProps, 'config'
| 'isResponsing'
| 'isResponding'
| 'chatList'
| 'showPromptLog'
| 'questionIcon'
@@ -29,7 +29,7 @@ type ChatContextProviderProps = {
export const ChatContextProvider = ({
children,
config,
isResponsing,
isResponding,
chatList,
showPromptLog,
questionIcon,
@@ -44,7 +44,7 @@ export const ChatContextProvider = ({
return (
<ChatContext.Provider value={{
config,
isResponsing,
isResponding,
chatList: chatList || [],
showPromptLog,
questionIcon,

View File

@@ -80,8 +80,8 @@ export const useChat = (
const { notify } = useToastContext()
const connversationId = useRef('')
const hasStopResponded = useRef(false)
const [isResponsing, setIsResponsing] = useState(false)
const isResponsingRef = useRef(false)
const [isResponding, setIsResponding] = useState(false)
const isRespondingRef = useRef(false)
const [chatList, setChatList] = useState<ChatItem[]>(prevChatList || [])
const chatListRef = useRef<ChatItem[]>(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,

View File

@@ -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<ChatProps> = ({
config,
onSend,
chatList,
isResponsing,
isResponding,
noStopResponding,
onStopResponding,
noChatInput,
@@ -125,7 +125,7 @@ const Chat: FC<ChatProps> = ({
<ChatContextProvider
config={config}
chatList={chatList}
isResponsing={isResponsing}
isResponding={isResponding}
showPromptLog={showPromptLog}
questionIcon={questionIcon}
answerIcon={answerIcon}
@@ -158,7 +158,7 @@ const Chat: FC<ChatProps> = ({
index={index}
config={config}
answerIcon={answerIcon}
responsing={isLast && isResponsing}
responding={isLast && isResponding}
allToolIcons={allToolIcons}
/>
)
@@ -169,7 +169,7 @@ const Chat: FC<ChatProps> = ({
item={item}
showPromptLog={showPromptLog}
questionIcon={questionIcon}
isResponsing={isResponsing}
isResponding={isResponding}
/>
)
})
@@ -188,7 +188,7 @@ const Chat: FC<ChatProps> = ({
className={`${chatFooterInnerClassName}`}
>
{
!noStopResponding && isResponsing && (
!noStopResponding && isResponding && (
<div className='flex justify-center mb-2'>
<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' />

View File

@@ -17,12 +17,12 @@ type QuestionProps = {
item: ChatItem
showPromptLog?: boolean
questionIcon?: ReactNode
isResponsing?: boolean
isResponding?: boolean
}
const Question: FC<QuestionProps> = ({
item,
showPromptLog,
isResponsing,
isResponding,
questionIcon,
}) => {
const ref = useRef(null)
@@ -38,7 +38,7 @@ const Question: FC<QuestionProps> = ({
<div className='group relative mr-4'>
<QuestionTriangle className='absolute -right-2 top-0 w-2 h-3 text-[#D1E9FF]/50' />
{
showPromptLog && !isResponsing && (
showPromptLog && !isResponding && (
<Log log={item.log!} containerRef={ref} />
)
}

View File

@@ -6,7 +6,7 @@ import { ssePost } from '@/service/base'
export const useTextGeneration = () => {
const { t } = useTranslation()
const { notify } = useToastContext()
const [isResponsing, setIsResponsing] = useState(false)
const [isResponding, setIsResponding] = useState(false)
const [completion, setCompletion] = useState('')
const [messageId, setMessageId] = useState<string | null>(null)
@@ -14,12 +14,12 @@ export const useTextGeneration = () => {
url: string,
data: any,
) => {
if (isResponsing) {
if (isResponding) {
notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') })
return false
}
setIsResponsing(true)
setIsResponding(true)
setCompletion('')
setMessageId('')
let res: string[] = []
@@ -42,10 +42,10 @@ export const useTextGeneration = () => {
setCompletion(res.join(''))
},
onCompleted() {
setIsResponsing(false)
setIsResponding(false)
},
onError() {
setIsResponsing(false)
setIsResponding(false)
},
})
return true
@@ -53,8 +53,8 @@ export const useTextGeneration = () => {
return {
completion,
isResponsing,
setIsResponsing,
isResponding,
setIsResponding,
handleSend,
messageId,
}