mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
🎨 feat: Title Improvements (#2363)
* fix(assistants): keep generated title upon continued messages in active conversation * feat: update document.title on successful gentitle mutation
This commit is contained in:
parent
6f0eb35365
commit
cc71125fa1
4 changed files with 10 additions and 4 deletions
|
|
@ -75,7 +75,6 @@ async function abortRun(req, res) {
|
||||||
});
|
});
|
||||||
|
|
||||||
const finalEvent = {
|
const finalEvent = {
|
||||||
title: 'New Chat',
|
|
||||||
final: true,
|
final: true,
|
||||||
conversation,
|
conversation,
|
||||||
runMessages,
|
runMessages,
|
||||||
|
|
|
||||||
|
|
@ -247,7 +247,6 @@ router.post('/', validateModel, buildEndpointOption, setHeaders, async (req, res
|
||||||
}
|
}
|
||||||
|
|
||||||
finalEvent = {
|
finalEvent = {
|
||||||
title: 'New Chat',
|
|
||||||
final: true,
|
final: true,
|
||||||
conversation: await getConvo(req.user.id, conversationId),
|
conversation: await getConvo(req.user.id, conversationId),
|
||||||
runMessages,
|
runMessages,
|
||||||
|
|
@ -477,7 +476,6 @@ router.post('/', validateModel, buildEndpointOption, setHeaders, async (req, res
|
||||||
|
|
||||||
conversation = {
|
conversation = {
|
||||||
conversationId,
|
conversationId,
|
||||||
title: 'New Chat',
|
|
||||||
endpoint: EModelEndpoint.assistants,
|
endpoint: EModelEndpoint.assistants,
|
||||||
promptPrefix: promptPrefix,
|
promptPrefix: promptPrefix,
|
||||||
instructions: instructions,
|
instructions: instructions,
|
||||||
|
|
@ -607,7 +605,6 @@ router.post('/', validateModel, buildEndpointOption, setHeaders, async (req, res
|
||||||
};
|
};
|
||||||
|
|
||||||
sendMessage(res, {
|
sendMessage(res, {
|
||||||
title: 'New Chat',
|
|
||||||
final: true,
|
final: true,
|
||||||
conversation,
|
conversation,
|
||||||
requestMessage: {
|
requestMessage: {
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ export const useGenTitleMutation = (): UseMutationResult<
|
||||||
title: response.title,
|
title: response.title,
|
||||||
} as TConversation);
|
} as TConversation);
|
||||||
});
|
});
|
||||||
|
document.title = response.title;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -192,10 +192,19 @@ export default function useSSE(submission: TSubmission | null, index = 0) {
|
||||||
|
|
||||||
let update = {} as TConversation;
|
let update = {} as TConversation;
|
||||||
setConversation((prevState) => {
|
setConversation((prevState) => {
|
||||||
|
let title = prevState?.title;
|
||||||
|
const parentId = requestMessage.parentMessageId;
|
||||||
|
if (parentId !== Constants.NO_PARENT && title?.toLowerCase()?.includes('new chat')) {
|
||||||
|
const convos = queryClient.getQueryData<ConversationData>([QueryKeys.allConversations]);
|
||||||
|
const cachedConvo = getConversationById(convos, conversationId);
|
||||||
|
title = cachedConvo?.title;
|
||||||
|
}
|
||||||
|
|
||||||
update = tConvoUpdateSchema.parse({
|
update = tConvoUpdateSchema.parse({
|
||||||
...prevState,
|
...prevState,
|
||||||
conversationId,
|
conversationId,
|
||||||
thread_id,
|
thread_id,
|
||||||
|
title,
|
||||||
messages: [requestMessage.messageId, responseMessage.messageId],
|
messages: [requestMessage.messageId, responseMessage.messageId],
|
||||||
}) as TConversation;
|
}) as TConversation;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue