chore: Update npm dependency versions and add export/import functions for chat history and knowledge

This commit is contained in:
n4ze3m
2024-05-08 12:13:16 +05:30
parent 88ad1fcab7
commit 11147fd951
5 changed files with 66 additions and 1 deletions

View File

@@ -417,3 +417,30 @@ export const getUserId = async () => {
}
return id
}
export const exportChatHistory = async () => {
const db = new PageAssitDatabase()
const chatHistories = await db.getChatHistories()
const messages = await Promise.all(
chatHistories.map(async (history) => {
const messages = await db.getChatHistory(history.id)
return { history, messages }
})
)
return messages
}
export const importChatHistory = async (
data: {
history: HistoryInfo
messages: MessageHistory
}[]
) => {
const db = new PageAssitDatabase()
for (const { history, messages } of data) {
await db.addChatHistory(history)
for (const message of messages) {
await db.addMessage(message)
}
}
}