feat: custom title and set history top

This commit is contained in:
archer
2023-05-29 22:24:49 +08:00
parent 7fe39c2515
commit 2fce76202a
11 changed files with 210 additions and 161 deletions

View File

@@ -77,15 +77,13 @@ export async function saveChat({
});
return _id;
} else {
// 已经有记录,追加入库
const chat = await Chat.findById(chatId);
await Chat.findByIdAndUpdate(chatId, {
$push: {
content: {
$each: content
}
},
...(chat && !chat.customTitle ? { title: content[0].value.slice(0, 20) } : {}),
title: content[0].value.slice(0, 20),
latestChat: content[1].value,
updateTime: new Date()
});