From ff6240d79804284a2053df30486aa70d750b156f Mon Sep 17 00:00:00 2001 From: josc146 Date: Wed, 3 Apr 2024 14:54:02 +0800 Subject: [PATCH] chore --- frontend/src/pages/Chat.tsx | 5 +++-- frontend/src/pages/Completion.tsx | 5 +++-- frontend/src/pages/Composition.tsx | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/frontend/src/pages/Chat.tsx b/frontend/src/pages/Chat.tsx index 2cd05ed..c37e54f 100644 --- a/frontend/src/pages/Chat.tsx +++ b/frontend/src/pages/Chat.tsx @@ -583,8 +583,9 @@ const ChatPanel: FC = observer(() => { }), signal: chatSseController?.signal, onmessage(e) { + if (finished) return; scrollToBottom(); - if (!finished && e.data.trim() === '[DONE]') { + if (e.data.trim() === '[DONE]') { finish(); return; } @@ -598,7 +599,7 @@ const ChatPanel: FC = observer(() => { if (data.model) commonStore.setLastModelName(data.model); if (data.choices && Array.isArray(data.choices) && data.choices.length > 0) { - if (!finished && data.choices[0]?.finish_reason) { + if (data.choices[0]?.finish_reason) { finish(); return; } diff --git a/frontend/src/pages/Completion.tsx b/frontend/src/pages/Completion.tsx index 1bc1bf1..1c54be2 100644 --- a/frontend/src/pages/Completion.tsx +++ b/frontend/src/pages/Completion.tsx @@ -109,8 +109,9 @@ const CompletionPanel: FC = observer(() => { }), signal: completionSseController?.signal, onmessage(e) { + if (finished) return; scrollToBottom(); - if (!finished && e.data.trim() === '[DONE]') { + if (e.data.trim() === '[DONE]') { finish(); return; } @@ -124,7 +125,7 @@ const CompletionPanel: FC = observer(() => { if (data.model) commonStore.setLastModelName(data.model); if (data.choices && Array.isArray(data.choices) && data.choices.length > 0) { - if (!finished && data.choices[0]?.finish_reason) { + if (data.choices[0]?.finish_reason) { finish(); return; } diff --git a/frontend/src/pages/Composition.tsx b/frontend/src/pages/Composition.tsx index 0a9030d..99ab0c3 100644 --- a/frontend/src/pages/Composition.tsx +++ b/frontend/src/pages/Composition.tsx @@ -214,8 +214,9 @@ const CompositionPanel: FC = observer(() => { }), signal: compositionSseController?.signal, onmessage(e) { + if (finished) return; scrollToBottom(); - if (!finished && e.data.trim() === '[DONE]') { + if (e.data.trim() === '[DONE]') { finish(); return; } @@ -229,7 +230,7 @@ const CompositionPanel: FC = observer(() => { if (data.model) commonStore.setLastModelName(data.model); if (data.choices && Array.isArray(data.choices) && data.choices.length > 0) { - if (!finished && data.choices[0]?.finish_reason) { + if (data.choices[0]?.finish_reason) { finish(); return; }