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) {
|
while (true) {
|
||||||
if (stopStreaming) {
|
if (stopStreaming) {
|
||||||
stopStreaming = false;
|
stopStreaming = false;
|
||||||
|
reader.cancel();
|
||||||
conversationHistory.push({ role: 'assistant', content: assistantResponseAccumulator });
|
conversationHistory.push({ role: 'assistant', content: assistantResponseAccumulator });
|
||||||
assistantResponseAccumulator = '';
|
assistantResponseAccumulator = '';
|
||||||
postMessage({ type: 'tokensDone' });
|
postMessage({ type: 'tokensDone' });
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const { done, value } = await reader.read();
|
const { done, value } = await reader.read();
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ self.onmessage = async function(event) {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (stopStreaming) {
|
if (stopStreaming) {
|
||||||
stopStreaming = false;
|
stopStreaming = false;
|
||||||
|
reader.cancel();
|
||||||
conversationHistory.push({ role: 'assistant', content: assistantResponseAccumulator });
|
conversationHistory.push({ role: 'assistant', content: assistantResponseAccumulator });
|
||||||
assistantResponseAccumulator = '';
|
assistantResponseAccumulator = '';
|
||||||
postMessage({ type: 'tokensDone' });
|
postMessage({ type: 'tokensDone' });
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue