The above code works in Postman, i.e when i make the api call, i get the message registered right away after 500ms.
But when I do the same call via UI, the message is not logged right away after 500ms. It waits for the connection to complete (i.e after 5s, i get all the message logged in the console)
UI code attached below:
sseTest() {
const authToken = this.localStorageService.get('tokenInfo')['accessToken'];
const eventSourceInitDict = {
headers: {
Authorization: 'Bearer ' + authToken
}
};
let url = '/api/ai/notes/chat-stream';
url += '?prompt=' + encodeURIComponent('How is Macrogenics addressing the toxicity issues seen with Vobra Duo in the dose expansion cohort?');
url += '&domainName=' + encodeURIComponent('AML_OVN_2021');
const es = new EventSourcePolyfill(url, eventSourceInitDict);
const listener = function(event) {
console.log(event);
};
es.addEventListener('open', listener);
es.addEventListener('message', (event) => {
console.log(event);
});
es.addEventListener('error', listener);
}
And the call is getting repeated in an infinite loop even if i'm calling the function only once.That's a weird part as well.
Any help on this will be greatly appreciated pls ?
Hi I'm using EventSource for making SSE call to my Java backend to build internal ChatGPT like application. Java Code below:
The above code works in Postman, i.e when i make the api call, i get the message registered right away after 500ms. But when I do the same call via UI, the message is not logged right away after 500ms. It waits for the connection to complete (i.e after 5s, i get all the message logged in the console)
UI code attached below:
And the call is getting repeated in an infinite loop even if i'm calling the function only once.That's a weird part as well.
Any help on this will be greatly appreciated pls ?
Thanks