js
const response = await fetch("http://127.0.0.1:7345/api/gpt/get", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
message: message.value,
role: role.value,
}),
});
if (!response.body) return;
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
while (true) {
var { value, done } = await reader.read();
if (done) break;
value = value?.replace("undefined", "");
console.log("received data -", value);
output.value += value?.replace("undefined", "");
}
JStar