chore: Update npm dependency versions and add export/import functions for chat history and knowledge
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user