perf: 中断SSE、更换测试环境接口
This commit is contained in:
@ -45,11 +45,16 @@ export default {
|
||||
initSse({ message });
|
||||
};
|
||||
|
||||
const clearSseController = () => {
|
||||
if (sseController.value) {
|
||||
sseController.value.abort?.();
|
||||
sseController.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
const handleCancel = () => {
|
||||
// 中止当前正在输出的回答
|
||||
console.log('handleCancel', currentTaskId.value);
|
||||
if (generateLoading.value) {
|
||||
bubbleListRef.value?.abortTypingByKey(currentTaskId.value);
|
||||
bubbleListRef.value?.abortTypingByKey(generateTeamRunTaskId.value);
|
||||
sseController.value?.abort?.();
|
||||
}
|
||||
if (showRightView.value) {
|
||||
@ -60,18 +65,15 @@ export default {
|
||||
antdMessage.info('取消生成');
|
||||
};
|
||||
|
||||
const initSse = (inputInfo: CHAT.TInputInfo): void => {
|
||||
if (sseController.value) {
|
||||
sseController.value.abort?.();
|
||||
sseController.value = null;
|
||||
}
|
||||
const initSse = async (inputInfo: CHAT.TInputInfo): Promise<void> => {
|
||||
clearSseController();
|
||||
|
||||
try {
|
||||
const { message } = inputInfo;
|
||||
|
||||
generateLoading.value = true;
|
||||
|
||||
sseController.value = querySSE({
|
||||
sseController.value = await querySSE({
|
||||
method: 'POST',
|
||||
handleMessage,
|
||||
body: JSON.stringify({
|
||||
@ -93,13 +95,11 @@ export default {
|
||||
agent_id: chatStore.agentInfo.agent_id,
|
||||
});
|
||||
if (code === 200) {
|
||||
conversationList.value = [
|
||||
...conversationList.value,
|
||||
...(data.list?.flat(1) ?? []).map((v) => ({
|
||||
...v,
|
||||
teamRunTaskId: v.step_run_id,
|
||||
})),
|
||||
];
|
||||
const remoteData = (data.list?.flat(1) ?? []).map((v: any) => ({
|
||||
...v,
|
||||
teamRunTaskId: v.step_run_id,
|
||||
}));
|
||||
conversationList.value = [...conversationList.value, ...remoteData];
|
||||
}
|
||||
};
|
||||
|
||||
@ -107,7 +107,7 @@ export default {
|
||||
roles,
|
||||
showRightView,
|
||||
rightViewData,
|
||||
currentTaskId,
|
||||
generateTeamRunTaskId,
|
||||
handleMessage,
|
||||
conversationList,
|
||||
generateLoading,
|
||||
@ -140,6 +140,10 @@ export default {
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
onUnmounted(() => {
|
||||
clearSseController();
|
||||
})
|
||||
|
||||
return () => (
|
||||
<div class="chat-view-wrap w-full h-full flex">
|
||||
<section class="flex-1 flex flex-col pt-20px justify-center relative px-16px">
|
||||
|
||||
Reference in New Issue
Block a user