fix variable conflict: rename stream buffer to avoid const redeclaration error
This commit is contained in:
parent
54f05b0af0
commit
10de872c6c
1 changed files with 4 additions and 4 deletions
|
|
@ -105,14 +105,14 @@ async function* sendMessageWithHistory(messageHistory) {
|
|||
|
||||
const reader = response.body.getReader();
|
||||
const decoder = new TextDecoder();
|
||||
let buffer = "";
|
||||
let streamBuffer = "";
|
||||
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
|
||||
buffer += decoder.decode(value, { stream: true });
|
||||
const lines = buffer.split("\n");
|
||||
streamBuffer += decoder.decode(value, { stream: true });
|
||||
const lines = streamBuffer.split("\n");
|
||||
|
||||
for (let i = 0; i < lines.length - 1; i++) {
|
||||
const line = lines[i].trim();
|
||||
|
|
@ -132,7 +132,7 @@ async function* sendMessageWithHistory(messageHistory) {
|
|||
}
|
||||
}
|
||||
|
||||
buffer = lines[lines.length - 1];
|
||||
streamBuffer = lines[lines.length - 1];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue