Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,537 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
try {
setStreamLoading(true);
setStreamComplete(false);
fetch(API_URL, requestOptions)
.then(response => {
// eslint-disable-next-line no-undef
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
function read() {
reader.read().then(({ done, value }) => {
if (done) {
console.log("Stream complete");
setStreamComplete(true)
return;
}
console.log(value, "asdsd")
if (value) {
setStreamChatResponse(value);
} else {
console.log('Error reading stream', value)
}
// Increment receivedResponses
read();
}).catch(error => {
console.error("Error reading stream", error);
setStreamComplete(false)
});
}
// Start reading response
read();
})
.catch(error => {
console.error("Fetch error", error);
setStreamComplete(false)
});
} catch (error) {
console.error("Stream processing error:", error);
} finally {
setStreamLoading(false);
setStreamComplete(false);
}