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

@@ -100,6 +100,18 @@ export class PageAssistVectorDb {
})
})
}
getAll = async (): Promise<VectorData[]> => {
return new Promise((resolve, reject) => {
this.db.get(null, (result) => {
if (chrome.runtime.lastError) {
reject(chrome.runtime.lastError)
} else {
resolve(Object.values(result))
}
})
})
}
}
export const insertVector = async (
@@ -127,3 +139,16 @@ export const deleteVectorByFileId = async (
const db = new PageAssistVectorDb()
return db.deleteVectorByFileId(id, file_id)
}
export const exportVectors = async () => {
const db = new PageAssistVectorDb()
const data = await db.getAll()
return data
}
export const importVectors = async (data: VectorData[]) => {
const db = new PageAssistVectorDb()
for (const d of data) {
await db.insertVector(d.id, d.vectors)
}
}