This commit is contained in:
Skylar Grant 2025-01-04 10:50:01 -05:00
parent 57f3197a39
commit 6ffe15ef9f

View File

@ -27,10 +27,16 @@ async function readResponse(response) {
try { try {
function read() { function read() {
let finishedResponse = '';
// Recursive function to read the stream // Recursive function to read the stream
reader.read().then(( chunk ) => { reader.read().then(( chunk ) => {
console.log(`Done: ${JSON.stringify(chunk.done)}`); console.log(`Done: ${JSON.stringify(chunk.done)}`);
console.log(`Value: ${new TextDecoder().decode(chunk.value)}`); console.log(`Value: ${new TextDecoder().decode(chunk.value)}`);
if (chunk.value) {
const text = decoder.decode(chunk.value, { stream: true });
finishedResponse += text;
outputArea.innerHTML = finishedResponse;
}
if (chunk.done) { if (chunk.done) {
return; return;
} }