Adding user session for history

Adding max record limt in settings
This commit is contained in:
sjiampojamarn 2025-04-05 15:14:25 -07:00
parent 8dc54efbdd
commit dce3a9eca0
5 changed files with 115 additions and 4 deletions

View file

@ -25,6 +25,7 @@ type Message = {
messageId: string;
chatId: string;
content: string;
userSessionId: string;
};
type ChatModel = {
@ -135,7 +136,7 @@ const handleHistorySave = async (
});
const fileData = files.map(getFileDetails);
let currentDate = new Date();
if (!chat) {
await db
.insert(chats)
@ -145,6 +146,8 @@ const handleHistorySave = async (
createdAt: new Date().toString(),
focusMode: focusMode,
files: fileData,
userSessionId: message.userSessionId,
timestamp: currentDate.toISOString(),
})
.execute();
} else if (JSON.stringify(chat.files ?? []) != JSON.stringify(fileData)) {