mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
fix: generate title by backend
This commit is contained in:
parent
3e7ce67609
commit
27515cb00a
6 changed files with 40 additions and 26 deletions
|
|
@ -138,13 +138,6 @@ router.post('/', async (req, res) => {
|
|||
return handleError(res, 'Prompt empty or too short');
|
||||
}
|
||||
|
||||
// if (!parentMessageId) {
|
||||
// gptResponse.title = await titleConvo({
|
||||
// model,
|
||||
// message: text,
|
||||
// response: JSON.stringify(gptResponse.text)
|
||||
// });
|
||||
// }
|
||||
gptResponse.sender = model === 'chatgptCustom' ? chatGptLabel : model;
|
||||
// gptResponse.final = true;
|
||||
gptResponse.text = await detectCode(gptResponse.text);
|
||||
|
|
@ -166,6 +159,19 @@ router.post('/', async (req, res) => {
|
|||
responseMessage: gptResponse
|
||||
});
|
||||
res.end();
|
||||
|
||||
if (parentMessageId == '00000000-0000-0000-0000-000000000000') {
|
||||
const title = await titleConvo({
|
||||
model,
|
||||
message: text,
|
||||
response: JSON.stringify(gptResponse?.text)
|
||||
});
|
||||
|
||||
await saveConvo({
|
||||
conversationId,
|
||||
title
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
// await deleteMessages({ messageId: userMessageId });
|
||||
|
|
|
|||
|
|
@ -72,14 +72,6 @@ router.post('/', async (req, res) => {
|
|||
userMessage.invocationId = response.invocationId;
|
||||
await saveMessage(userMessage);
|
||||
|
||||
// if (!convo.conversationSignature) {
|
||||
// response.title = await titleConvo({
|
||||
// model,
|
||||
// message: text,
|
||||
// response: JSON.stringify(response.response)
|
||||
// });
|
||||
// }
|
||||
|
||||
response.text = response.response;
|
||||
delete response.response;
|
||||
// response.id = response.details.messageId;
|
||||
|
|
@ -104,6 +96,19 @@ router.post('/', async (req, res) => {
|
|||
responseMessage: gptResponse
|
||||
});
|
||||
res.end();
|
||||
|
||||
if (parentMessageId == '00000000-0000-0000-0000-000000000000') {
|
||||
const title = await titleConvo({
|
||||
model,
|
||||
message: text,
|
||||
response: JSON.stringify(gptResponse?.text)
|
||||
});
|
||||
|
||||
await saveConvo({
|
||||
conversationId,
|
||||
title
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
// await deleteMessages({ messageId: userMessageId });
|
||||
|
|
|
|||
|
|
@ -73,13 +73,6 @@ router.post('/', async (req, res) => {
|
|||
// response.parentMessageId = convo.parentMessageId ? convo.parentMessageId : response.messageId;
|
||||
response.parentMessageId = response.messageId;
|
||||
response.invocationId = convo.invocationId ? convo.invocationId + 1 : 1;
|
||||
response.title = convo.jailbreakConversationId
|
||||
? await getConvoTitle(conversationId)
|
||||
: await titleConvo({
|
||||
model,
|
||||
message: text,
|
||||
response: JSON.stringify(response.response)
|
||||
});
|
||||
response.conversationId = conversationId
|
||||
? conversationId
|
||||
: crypto.randomUUID();
|
||||
|
|
@ -114,6 +107,19 @@ router.post('/', async (req, res) => {
|
|||
responseMessage: gptResponse
|
||||
});
|
||||
res.end();
|
||||
|
||||
if (parentMessageId == '00000000-0000-0000-0000-000000000000') {
|
||||
const title = await titleConvo({
|
||||
model,
|
||||
message: text,
|
||||
response: JSON.stringify(gptResponse?.text)
|
||||
});
|
||||
|
||||
await saveConvo({
|
||||
conversationId,
|
||||
title
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
// await deleteMessages({ messageId: userMessageId });
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ export default function Conversation({
|
|||
);
|
||||
}
|
||||
const data = await trigger();
|
||||
console.log('data', data);
|
||||
|
||||
if (chatGptLabel) {
|
||||
dispatch(setModel('chatgptCustom'));
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ export default function TextChat({ messages }) {
|
|||
|
||||
const changeHandler = (e) => {
|
||||
const { value } = e.target;
|
||||
console.log(value)
|
||||
|
||||
if (isSubmitting && (value === '' || value === '\n')) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@ const Messages = ({ messages }) => {
|
|||
|
||||
const messageTree = useMemo(() => buildTree(messages), [messages, ]);
|
||||
|
||||
console.log('messageTree', messageTree);
|
||||
|
||||
function buildTree(messages) {
|
||||
let messageMap = {};
|
||||
let rootMessages = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue