Skip to content

Commit

Permalink
Awaiting whole anser of old thread
Browse files Browse the repository at this point in the history
  • Loading branch information
Bianca Wentzel committed Sep 20, 2024
1 parent 2fb2510 commit 60ec059
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions assets/js/Containers/FrevaGPT/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,8 @@ const ChatBot = () => {
thread_id: thread.current,
}).toString());

const reader = response.body.getReader();
const decoder = new TextDecoder('utf-8');

let buffer = "";

// eslint-disable-next-line no-constant-condition
while (true) {
// eslint-disable-next-line no-await-in-loop
const { done, value } = await reader.read();
if (done) break;

const decodedValues = decoder.decode(value);
buffer = buffer + decodedValues;

try {
const threadContent = JSON.parse(buffer);
setConversation(threadContent);
} catch(err) {
// do something
console.log(err);
}
}
const variantArray = await response.json();
setConversation(variantArray);
}

const fetchData = async () => {
Expand Down

0 comments on commit 60ec059

Please sign in to comment.