adds bing ai functionality, still need to code out message/convo storing since it returns a lot of useful parameters

This commit is contained in:
Danny Avila 2023-02-15 12:29:56 -05:00
parent e0a26f52cd
commit 5c7000c273
11 changed files with 462 additions and 21 deletions

View file

@ -1,4 +1,5 @@
import { SSE } from '../../app/sse';
const endpoint = 'http://localhost:3050/ask';
export default function handleSubmit({
model,
@ -17,7 +18,8 @@ export default function handleSubmit({
};
}
const events = new SSE('http://localhost:3050/ask', {
const server = model === 'bingai' ? endpoint + '/bing' : endpoint;
const events = new SSE(server, {
payload: JSON.stringify(payload),
headers: { 'Content-Type': 'application/json' }
});
@ -28,8 +30,9 @@ export default function handleSubmit({
events.onmessage = function (e) {
const data = JSON.parse(e.data);
const text = data.text || data.response;
if (!!data.message) {
messageHandler(data.text.replace(/^\n/, ''));
messageHandler(text.replace(/^\n/, ''));
} else if (!!data.final) {
console.log(data);
convoHandler(data);