really closing the connection to the server when stopped by the user.
This commit is contained in:
parent
d7cef5dceb
commit
c66927f472
2 changed files with 3 additions and 0 deletions
|
|
@ -65,9 +65,11 @@ self.onmessage = async function(event) {
|
|||
while (true) {
|
||||
if (stopStreaming) {
|
||||
stopStreaming = false;
|
||||
reader.cancel();
|
||||
conversationHistory.push({ role: 'assistant', content: assistantResponseAccumulator });
|
||||
assistantResponseAccumulator = '';
|
||||
postMessage({ type: 'tokensDone' });
|
||||
|
||||
break;
|
||||
}
|
||||
const { done, value } = await reader.read();
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ self.onmessage = async function(event) {
|
|||
while (true) {
|
||||
if (stopStreaming) {
|
||||
stopStreaming = false;
|
||||
reader.cancel();
|
||||
conversationHistory.push({ role: 'assistant', content: assistantResponseAccumulator });
|
||||
assistantResponseAccumulator = '';
|
||||
postMessage({ type: 'tokensDone' });
|
||||
|
|
|
|||
Loading…
Reference in a new issue