mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
chore: hotfix for browser client
This commit is contained in:
parent
0405206438
commit
80ca3bc375
3 changed files with 21 additions and 5 deletions
|
|
@ -17,7 +17,9 @@ router.post('/', async (req, res) => {
|
|||
return handleError(res, { text: 'Prompt empty or too short' });
|
||||
}
|
||||
|
||||
console.log('model:', model, 'oldConvoId:', oldConversationId);
|
||||
const conversationId = oldConversationId || crypto.randomUUID();
|
||||
console.log('conversationId after old:', conversationId);
|
||||
|
||||
const userMessageId = crypto.randomUUID();
|
||||
const userParentMessageId = parentMessageId || '00000000-0000-0000-0000-000000000000';
|
||||
|
|
@ -36,7 +38,7 @@ router.post('/', async (req, res) => {
|
|||
...convo
|
||||
});
|
||||
|
||||
if (!overrideParentMessageId) {
|
||||
if (!overrideParentMessageId && model !== 'chatgptBrowser') {
|
||||
await saveMessage(userMessage);
|
||||
await saveConvo(req?.session?.user?.username, { ...userMessage, model, ...convo });
|
||||
}
|
||||
|
|
@ -144,10 +146,11 @@ const ask = async ({
|
|||
// gptResponse.final = true;
|
||||
gptResponse.text = await handleText(gptResponse);
|
||||
|
||||
|
||||
if (convo.chatGptLabel?.length > 0 && model === 'chatgptCustom') {
|
||||
gptResponse.chatGptLabel = convo.chatGptLabel;
|
||||
}
|
||||
|
||||
|
||||
if (convo.promptPrefix?.length > 0 && model === 'chatgptCustom') {
|
||||
gptResponse.promptPrefix = convo.promptPrefix;
|
||||
}
|
||||
|
|
@ -155,6 +158,11 @@ const ask = async ({
|
|||
// override the parentMessageId, for the regeneration.
|
||||
gptResponse.parentMessageId = overrideParentMessageId || userMessageId;
|
||||
|
||||
/* this is a hacky solution to get the browserClient working right, will refactor later */
|
||||
if (model === 'chatgptBrowser' && userParentMessageId.startsWith('000')) {
|
||||
await saveMessage({ ...userMessage, conversationId: gptResponse.conversationId });
|
||||
}
|
||||
|
||||
await saveMessage(gptResponse);
|
||||
await saveConvo(req?.session?.user?.username, gptResponse);
|
||||
sendMessage(res, {
|
||||
|
|
@ -171,7 +179,8 @@ const ask = async ({
|
|||
await saveConvo(
|
||||
req?.session?.user?.username,
|
||||
{
|
||||
conversationId,
|
||||
/* again, for sake of browser client, will soon refactor */
|
||||
conversationId: model === 'chatgptBrowser' ? gptResponse.conversationId : conversationId,
|
||||
title
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue