fix/refac: use user prompt for title gen fallback

This commit is contained in:
Timothy J. Baek 2024-10-28 05:34:50 -07:00
parent a64cc8f8e0
commit 25a2c6ee52

View File

@ -1895,20 +1895,21 @@
}; };
const generateChatTitle = async (messages) => { const generateChatTitle = async (messages) => {
const lastUserMessage = messages.filter((message) => message.role === 'user').at(-1);
if ($settings?.title?.auto ?? true) { if ($settings?.title?.auto ?? true) {
const lastMessage = messages.at(-1);
const modelId = selectedModels[0]; const modelId = selectedModels[0];
const title = await generateTitle(localStorage.token, modelId, messages, $chatId).catch( const title = await generateTitle(localStorage.token, modelId, messages, $chatId).catch(
(error) => { (error) => {
console.error(error); console.error(error);
return 'New Chat'; return lastUserMessage?.content ?? 'New Chat';
} }
); );
return title; return title;
} else { } else {
return 'New Chat'; return lastUserMessage?.content ?? 'New Chat';
} }
}; };