|
|
|
@@ -75,6 +75,8 @@ const Debug: FC<IDebug> = ({ |
|
|
|
const [abortController, setAbortController] = useState<AbortController | null>(null) |
|
|
|
const [isShowFormattingChangeConfirm, setIsShowFormattingChangeConfirm] = useState(false) |
|
|
|
const [isShowSuggestion, setIsShowSuggestion] = useState(false) |
|
|
|
const [messageTaskId, setMessageTaskId] = useState('') |
|
|
|
const [hasStopResponded, setHasStopResponded, getHasStopResponded] = useGetState(false) |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
if (formattingChanged && chatList.some(item => !item.isAnswer)) |
|
|
|
@@ -83,7 +85,7 @@ const Debug: FC<IDebug> = ({ |
|
|
|
setFormattingChanged(false) |
|
|
|
}, [formattingChanged]) |
|
|
|
|
|
|
|
const clearConversation = () => { |
|
|
|
const clearConversation = async () => { |
|
|
|
setConversationId(null) |
|
|
|
abortController?.abort() |
|
|
|
setResponsingFalse() |
|
|
|
@@ -136,7 +138,6 @@ const Debug: FC<IDebug> = ({ |
|
|
|
|
|
|
|
const doShowSuggestion = isShowSuggestion && !isResponsing |
|
|
|
const [suggestQuestions, setSuggestQuestions] = useState<string[]>([]) |
|
|
|
const [messageTaskId, setMessageTaskId] = useState('') |
|
|
|
const onSend = async (message: string) => { |
|
|
|
if (isResponsing) { |
|
|
|
notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') }) |
|
|
|
@@ -203,6 +204,7 @@ const Debug: FC<IDebug> = ({ |
|
|
|
|
|
|
|
let _newConversationId: null | string = null |
|
|
|
|
|
|
|
setHasStopResponded(false) |
|
|
|
setResponsingTrue() |
|
|
|
setIsShowSuggestion(false) |
|
|
|
sendChatMessage(appId, data, { |
|
|
|
@@ -255,7 +257,7 @@ const Debug: FC<IDebug> = ({ |
|
|
|
} |
|
|
|
})) |
|
|
|
} |
|
|
|
if (suggestedQuestionsAfterAnswerConfig.enabled) { |
|
|
|
if (suggestedQuestionsAfterAnswerConfig.enabled && !getHasStopResponded()) { |
|
|
|
const { data }: any = await fetchSuggestedQuestions(appId, responseItem.id) |
|
|
|
setSuggestQuestions(data) |
|
|
|
setIsShowSuggestion(true) |
|
|
|
@@ -379,8 +381,8 @@ const Debug: FC<IDebug> = ({ |
|
|
|
isResponsing={isResponsing} |
|
|
|
canStopResponsing={!!messageTaskId} |
|
|
|
abortResponsing={async () => { |
|
|
|
abortController?.abort() |
|
|
|
await stopChatMessageResponding(appId, messageTaskId) |
|
|
|
setHasStopResponded(true) |
|
|
|
setResponsingFalse() |
|
|
|
}} |
|
|
|
isShowSuggestion={doShowSuggestion} |
|
|
|
@@ -399,6 +401,7 @@ const Debug: FC<IDebug> = ({ |
|
|
|
className="mt-2" |
|
|
|
content={completionRes} |
|
|
|
isLoading={!completionRes && isResponsing} |
|
|
|
isInstalledApp={false} |
|
|
|
/> |
|
|
|
)} |
|
|
|
</div> |