really closing the connection to the server when stopped by the user.

This commit is contained in:
mic 2024-08-22 22:42:02 +02:00
parent d7cef5dceb
commit c66927f472
2 changed files with 3 additions and 0 deletions

View file

@ -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();

View file

@ -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' });