|
@@ -14,7 +14,7 @@ import { ToastContext } from '@/app/components/base/toast'
|
|
|
import Sidebar from '@/app/components/share/chat/sidebar'
|
|
|
import ConfigSence from '@/app/components/share/chat/config-scence'
|
|
|
import Header from '@/app/components/share/header'
|
|
|
-import { fetchAppInfo, fetchAppParams, fetchChatList, fetchConversations, fetchSuggestedQuestions, sendChatMessage, updateFeedback } from '@/service/share'
|
|
|
+import { fetchAppInfo, fetchAppParams, fetchChatList, fetchConversations, fetchSuggestedQuestions, sendChatMessage, stopChatMessageResponding, updateFeedback } from '@/service/share'
|
|
|
import type { ConversationItem, SiteInfo } from '@/models/share'
|
|
|
import type { PromptConfig, SuggestedQuestionsAfterAnswerConfig } from '@/models/debug'
|
|
|
import type { Feedbacktype, IChatItem } from '@/app/components/app/chat'
|
|
@@ -332,6 +332,7 @@ const Main: FC<IMainProps> = ({
|
|
|
const [isShowSuggestion, setIsShowSuggestion] = useState(false)
|
|
|
const doShowSuggestion = isShowSuggestion && !isResponsing
|
|
|
const [suggestQuestions, setSuggestQuestions] = useState<string[]>([])
|
|
|
+ const [messageTaskId, setMessageTaskId] = useState('')
|
|
|
const handleSend = async (message: string) => {
|
|
|
if (isResponsing) {
|
|
|
notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') })
|
|
@@ -376,12 +377,13 @@ const Main: FC<IMainProps> = ({
|
|
|
getAbortController: (abortController) => {
|
|
|
setAbortController(abortController)
|
|
|
},
|
|
|
- onData: (message: string, isFirstMessage: boolean, { conversationId: newConversationId, messageId }: any) => {
|
|
|
+ onData: (message: string, isFirstMessage: boolean, { conversationId: newConversationId, messageId, taskId }: any) => {
|
|
|
responseItem.content = responseItem.content + message
|
|
|
responseItem.id = messageId
|
|
|
if (isFirstMessage && newConversationId)
|
|
|
tempNewConversationId = newConversationId
|
|
|
|
|
|
+ setMessageTaskId(taskId)
|
|
|
// closesure new list is outdated.
|
|
|
const newListWithAnswer = produce(
|
|
|
getChatList().filter(item => item.id !== responseItem.id && item.id !== placeholderAnswerId),
|
|
@@ -532,8 +534,10 @@ const Main: FC<IMainProps> = ({
|
|
|
isHideFeedbackEdit
|
|
|
onFeedback={handleFeedback}
|
|
|
isResponsing={isResponsing}
|
|
|
- abortResponsing={() => {
|
|
|
+ canStopResponsing={!!messageTaskId}
|
|
|
+ abortResponsing={async () => {
|
|
|
abortController?.abort()
|
|
|
+ await stopChatMessageResponding(appId, messageTaskId, isInstalledApp, installedAppInfo?.id)
|
|
|
setResponsingFalse()
|
|
|
}}
|
|
|
checkCanSend={checkCanSend}
|