fix: webapp stop chat & citation (#2376)
This commit is contained in:
@@ -11,6 +11,7 @@ import ConfigPanel from './config-panel'
|
||||
import {
|
||||
fetchSuggestedQuestions,
|
||||
getUrl,
|
||||
stopChatMessageResponding,
|
||||
} from '@/service/share'
|
||||
|
||||
const ChatWrapper = () => {
|
||||
@@ -47,6 +48,7 @@ const ChatWrapper = () => {
|
||||
appConfig,
|
||||
undefined,
|
||||
appPrevChatList,
|
||||
taskId => stopChatMessageResponding('', taskId, isInstalledApp, appId),
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
|
@@ -97,7 +97,7 @@ const Answer: FC<AnswerProps> = ({
|
||||
<SuggestedQuestions item={item} />
|
||||
{
|
||||
!!citation?.length && config?.retriever_resource?.enabled && !responsing && (
|
||||
<Citation data={citation} showHitInfo />
|
||||
<Citation data={citation} showHitInfo={config.supportCitationHitInfo} />
|
||||
)
|
||||
}
|
||||
</div>
|
||||
|
@@ -87,7 +87,6 @@ export const useChat = (
|
||||
const chatListRef = useRef<ChatItem[]>(prevChatList || [])
|
||||
const taskIdRef = useRef('')
|
||||
const [suggestedQuestions, setSuggestQuestions] = useState<string[]>([])
|
||||
const abortControllerRef = useRef<AbortController | null>(null)
|
||||
const conversationMessagesAbortControllerRef = useRef<AbortController | null>(null)
|
||||
const suggestedQuestionsAbortControllerRef = useRef<AbortController | null>(null)
|
||||
const checkPromptVariables = useCheckPromptVariables()
|
||||
@@ -131,8 +130,6 @@ export const useChat = (
|
||||
handleResponsing(false)
|
||||
if (stopChat && taskIdRef.current)
|
||||
stopChat(taskIdRef.current)
|
||||
if (abortControllerRef.current)
|
||||
abortControllerRef.current.abort()
|
||||
if (conversationMessagesAbortControllerRef.current)
|
||||
conversationMessagesAbortControllerRef.current.abort()
|
||||
if (suggestedQuestionsAbortControllerRef.current)
|
||||
@@ -192,6 +189,8 @@ 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
|
||||
@@ -257,9 +256,6 @@ export const useChat = (
|
||||
},
|
||||
{
|
||||
isPublicAPI,
|
||||
getAbortController: (abortController) => {
|
||||
abortControllerRef.current = abortController
|
||||
},
|
||||
onData: (message: string, isFirstMessage: boolean, { conversationId: newConversationId, messageId, taskId }: any) => {
|
||||
if (!isAgentMode) {
|
||||
responseItem.content = responseItem.content + message
|
||||
|
@@ -45,6 +45,7 @@ export type ChatConfig = Omit<ModelConfig, 'model'> & {
|
||||
supportAnnotation?: boolean
|
||||
appId?: string
|
||||
supportFeedback?: boolean
|
||||
supportCitationHitInfo?: boolean
|
||||
}
|
||||
|
||||
export type ChatItem = IChatItem
|
||||
|
Reference in New Issue
Block a user