mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 17:30:16 +01:00
persist bing ai conversation
This commit is contained in:
parent
81e52fed73
commit
7b7548c905
4 changed files with 28 additions and 8 deletions
|
|
@ -18,7 +18,7 @@ const messageSchema = mongoose.Schema({
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
invocationId: {
|
invocationId: {
|
||||||
type: Number,
|
type: String,
|
||||||
},
|
},
|
||||||
parentMessageId: {
|
parentMessageId: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,8 @@ router.post('/bing', async (req, res) => {
|
||||||
convo
|
convo
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('CLIENT RESPONSE');
|
// console.log('CLIENT RESPONSE');
|
||||||
console.dir(response, { depth: null });
|
// console.dir(response, { depth: null });
|
||||||
|
|
||||||
userMessage.conversationSignature =
|
userMessage.conversationSignature =
|
||||||
convo.conversationSignature || response.conversationSignature;
|
convo.conversationSignature || response.conversationSignature;
|
||||||
|
|
@ -72,7 +72,7 @@ router.post('/bing', async (req, res) => {
|
||||||
|
|
||||||
response.text = response.response;
|
response.text = response.response;
|
||||||
response.id = response.details.messageId;
|
response.id = response.details.messageId;
|
||||||
response.suggestions = response.details.suggestedResponses.map((s) => s.text);
|
response.suggestions = response.details.suggestedResponses && response.details.suggestedResponses.map((s) => s.text);
|
||||||
response.sender = model;
|
response.sender = model;
|
||||||
response.final = true;
|
response.final = true;
|
||||||
await saveMessage(response);
|
await saveMessage(response);
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,17 @@ export default function TextChat({ messages }) {
|
||||||
const { title, conversationId, id } = data;
|
const { title, conversationId, id } = data;
|
||||||
console.log('parentMessageId is null');
|
console.log('parentMessageId is null');
|
||||||
console.log('title, convoId, id', title, conversationId, id);
|
console.log('title, convoId, id', title, conversationId, id);
|
||||||
dispatch(setConversation({ title, conversationId, parentMessageId: id }));
|
dispatch(
|
||||||
} else if (convo.conversationSignature === null) {
|
setConversation({
|
||||||
|
title,
|
||||||
|
conversationId,
|
||||||
|
parentMessageId: id,
|
||||||
|
conversationSignature: null,
|
||||||
|
clientId: null,
|
||||||
|
invocationId: null
|
||||||
|
})
|
||||||
|
);
|
||||||
|
} else if (convo.invocationId === null) {
|
||||||
const { title, conversationSignature, clientId, conversationId, invocationId } = data;
|
const { title, conversationSignature, clientId, conversationId, invocationId } = data;
|
||||||
console.log('convoSig is null');
|
console.log('convoSig is null');
|
||||||
console.log(
|
console.log(
|
||||||
|
|
@ -60,7 +69,8 @@ export default function TextChat({ messages }) {
|
||||||
conversationSignature,
|
conversationSignature,
|
||||||
clientId,
|
clientId,
|
||||||
conversationId,
|
conversationId,
|
||||||
invocationId
|
invocationId,
|
||||||
|
parentMessageId: null
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -160,4 +170,4 @@ export default function TextChat({ messages }) {
|
||||||
<Footer />
|
<Footer />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,16 @@ export default function handleSubmit({
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (model === 'bingai' && convo.conversationId) {
|
||||||
|
payload = {
|
||||||
|
...payload,
|
||||||
|
conversationId: convo.conversationId,
|
||||||
|
conversationSignature: convo.conversationSignature,
|
||||||
|
clientId: convo.clientId,
|
||||||
|
invocationId: convo.invocationId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const server = model === 'bingai' ? endpoint + '/bing' : endpoint;
|
const server = model === 'bingai' ? endpoint + '/bing' : endpoint;
|
||||||
const events = new SSE(server, {
|
const events = new SSE(server, {
|
||||||
payload: JSON.stringify(payload),
|
payload: JSON.stringify(payload),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue