Knowledge base
Manage your knowledge bases
diff --git a/src/stores/knowledge.ts b/src/stores/knowledge.ts
index 3d0340c..54439b6 100644
--- a/src/stores/knowledge.ts
+++ b/src/stores/knowledge.ts
@@ -93,7 +93,11 @@ export const useKnowledgeStore = defineStore('knowledge', {
await alephStorage.deleteFile(document.store.item_hash);
if (updateKnowledgeBase) {
- await this.updateKnowledgeBase(knowledgeBase, kbIdentifier);
+ const newKnowledgeBase: KnowledgeBase = {
+ ...knowledgeBase,
+ documents: knowledgeBase.documents.filter((d) => d.id !== document.id),
+ };
+ await this.updateKnowledgeBase(newKnowledgeBase, kbIdentifier);
}
},
diff --git a/src/utils/aleph-persistent-storage.ts b/src/utils/aleph-persistent-storage.ts
index 3a8b2be..c4a86c9 100644
--- a/src/utils/aleph-persistent-storage.ts
+++ b/src/utils/aleph-persistent-storage.ts
@@ -118,13 +118,12 @@ export class AlephPersistentStorage {
async saveSettings(content: object) {
try {
- const message = await this.subAccountClient.createAggregate({
+ await this.subAccountClient.createAggregate({
key: LIBERTAI_SETTINGS_KEY,
content,
address: this.account.address,
channel: LIBERTAI_CHANNEL,
});
- console.log(`Settings saved on Aleph with hash ${message.item_hash}`);
} catch (error) {
console.error(`Saving settings on Aleph failed: ${error}`);
}
@@ -191,6 +190,7 @@ export class AlephPersistentStorage {
content: encryptedKb,
address: this.account.address,
channel: LIBERTAI_CHANNEL,
+ storageEngine: ItemType.storage,
});
const identifier: KnowledgeBaseIdentifier = {
@@ -228,6 +228,7 @@ export class AlephPersistentStorage {
content: encryptedKb,
address: this.account.address,
channel: LIBERTAI_CHANNEL,
+ storageEngine: ItemType.storage,
});
} catch (error) {
console.error(`Update of knowledge base ${knowledgeBase.id} failed: ${error}`);
diff --git a/src/utils/knowledge/parsing.ts b/src/utils/knowledge/parsing.ts
index e1104ee..fc7279e 100644
--- a/src/utils/knowledge/parsing.ts
+++ b/src/utils/knowledge/parsing.ts
@@ -2,6 +2,8 @@ import mime from 'mime';
import * as pdfjs from 'pdfjs-dist';
import { TextItem } from 'pdfjs-dist/types/src/display/api';
+export const supportedInputFiles = ['.txt', '.md', '.pdf'].join(',');
+
const extractTextFromPdfFile = async (file: File): Promise => {
const pdfUrl = URL.createObjectURL(file);