wrap code in progress, revert old message handling

This commit is contained in:
Daniel Avila 2023-02-25 09:06:26 -05:00
parent 0f6fcd5928
commit ed699d2c06
6 changed files with 121 additions and 1438 deletions

View file

@ -36,66 +36,66 @@ export default function TextChat({ messages }) {
const messageHandler = (data) => {
dispatch(setMessages([...messages, currentMsg, { sender: model, text: data }]));
};
// const convoHandler = (data) => {
// dispatch(
// setMessages([...messages, { sender: model, text: data.text || data.response }])
// );
// if (
// model !== 'bingai' &&
// convo.conversationId === null &&
// convo.parentMessageId === null
// ) {
// const { title, conversationId, id } = data;
// dispatch(
// setConversation({
// title,
// conversationId,
// parentMessageId: id,
// conversationSignature: null,
// clientId: null,
// invocationId: null
// })
// );
// } else if (
// model === 'bingai' &&
// convo.conversationId === null &&
// convo.invocationId === null
// ) {
// const { title, conversationSignature, clientId, conversationId, invocationId } = data;
// dispatch(
// setConversation({
// title,
// conversationSignature,
// clientId,
// conversationId,
// invocationId,
// parentMessageId: null
// })
// );
// }
// dispatch(setSubmitState(false));
// };
const convoHandler = (data) => {
const { conversationId, id, invocationId, text } = data;
const conversationData = {
title: data.title,
conversationId,
parentMessageId:
model !== 'bingai' && !convo.conversationId && !convo.parentMessageId ? id : null,
conversationSignature:
model === 'bingai' && !convo.conversationId ? data.conversationSignature : null,
clientId: model === 'bingai' && !convo.conversationId ? data.clientId : null,
// invocationId: model === 'bingai' && !convo.conversationId ? data.invocationId : null
invocationId: invocationId ? invocationId : null
};
dispatch(setMessages([...messages, currentMsg, { sender: model, text: text || data.response }]));
dispatch(setConversation(conversationData));
dispatch(
setMessages([...messages, currentMsg, { sender: model, text: data.text || data.response }])
);
if (
model !== 'bingai' &&
convo.conversationId === null &&
convo.parentMessageId === null
) {
const { title, conversationId, id } = data;
dispatch(
setConversation({
title,
conversationId,
parentMessageId: id,
conversationSignature: null,
clientId: null,
invocationId: null
})
);
} else if (
model === 'bingai' &&
convo.conversationId === null &&
convo.invocationId === null
) {
const { title, conversationSignature, clientId, conversationId, invocationId } = data;
dispatch(
setConversation({
title,
conversationSignature,
clientId,
conversationId,
invocationId,
parentMessageId: null
})
);
}
dispatch(setSubmitState(false));
};
// const convoHandler = (data) => {
// const { conversationId, id, invocationId } = data;
// const conversationData = {
// title: data.title,
// conversationId,
// parentMessageId:
// model !== 'bingai' && !convo.conversationId && !convo.parentMessageId ? id : null,
// conversationSignature:
// model === 'bingai' && !convo.conversationId ? data.conversationSignature : null,
// clientId: model === 'bingai' && !convo.conversationId ? data.clientId : null,
// // invocationId: model === 'bingai' && !convo.conversationId ? data.invocationId : null
// invocationId: invocationId ? invocationId : null
// };
// dispatch(setMessages([...messages, currentMsg, { sender: model, text: data.text || data.response }]));
// dispatch(setConversation(conversationData));
// dispatch(setSubmitState(false));
// };
const errorHandler = (event) => {
console.log('Error:', event);
const errorResponse = {