🎨 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:
Danny Avila 2024-04-09 14:01:27 -04:00 committed by GitHub
parent 6f0eb35365
commit cc71125fa1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 4 deletions

View file

@ -75,7 +75,6 @@ async function abortRun(req, res) {
});
const finalEvent = {
title: 'New Chat',
final: true,
conversation,
runMessages,

View file

@ -247,7 +247,6 @@ router.post('/', validateModel, buildEndpointOption, setHeaders, async (req, res
}
finalEvent = {
title: 'New Chat',
final: true,
conversation: await getConvo(req.user.id, conversationId),
runMessages,
@ -477,7 +476,6 @@ router.post('/', validateModel, buildEndpointOption, setHeaders, async (req, res
conversation = {
conversationId,
title: 'New Chat',
endpoint: EModelEndpoint.assistants,
promptPrefix: promptPrefix,
instructions: instructions,
@ -607,7 +605,6 @@ router.post('/', validateModel, buildEndpointOption, setHeaders, async (req, res
};
sendMessage(res, {
title: 'New Chat',
final: true,
conversation,
requestMessage: {

View file

@ -68,6 +68,7 @@ export const useGenTitleMutation = (): UseMutationResult<
title: response.title,
} as TConversation);
});
document.title = response.title;
},
});
};

View file

@ -192,10 +192,19 @@ export default function useSSE(submission: TSubmission | null, index = 0) {
let update = {} as TConversation;
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({
...prevState,
conversationId,
thread_id,
title,
messages: [requestMessage.messageId, responseMessage.messageId],
}) as TConversation;