fix: playground

This commit is contained in:
Timothy J. Baek 2024-06-09 17:38:08 -07:00
parent b565301a47
commit bc1a7ab567

View File

@ -80,8 +80,6 @@
if (stopResponseFlag) { if (stopResponseFlag) {
controller.abort('User: Stop Response'); controller.abort('User: Stop Response');
} }
currentRequestId = null;
break; break;
} }
@ -97,11 +95,7 @@
let data = JSON.parse(line.replace(/^data: /, '')); let data = JSON.parse(line.replace(/^data: /, ''));
console.log(data); console.log(data);
if ('request_id' in data) { text += data.choices[0].delta.content ?? '';
currentRequestId = data.request_id;
} else {
text += data.choices[0].delta.content ?? '';
}
} }
} }
} }
@ -178,21 +172,17 @@
let data = JSON.parse(line.replace(/^data: /, '')); let data = JSON.parse(line.replace(/^data: /, ''));
console.log(data); console.log(data);
if ('request_id' in data) { if (responseMessage.content == '' && data.choices[0].delta.content == '\n') {
currentRequestId = data.request_id; continue;
} else { } else {
if (responseMessage.content == '' && data.choices[0].delta.content == '\n') { textareaElement.style.height = textareaElement.scrollHeight + 'px';
continue;
} else {
textareaElement.style.height = textareaElement.scrollHeight + 'px';
responseMessage.content += data.choices[0].delta.content ?? ''; responseMessage.content += data.choices[0].delta.content ?? '';
messages = messages; messages = messages;
textareaElement.style.height = textareaElement.scrollHeight + 'px'; textareaElement.style.height = textareaElement.scrollHeight + 'px';
await tick(); await tick();
}
} }
} }
} }