From eca5b4e81f3f7ef7bd06266ef7c13cd443ab17ee Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Wed, 13 Nov 2024 10:38:59 -0300 Subject: [PATCH] fix(kb.gbapp): Cleaning vector store before indexing. --- packages/kb.gbapp/services/KBService.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/kb.gbapp/services/KBService.ts b/packages/kb.gbapp/services/KBService.ts index 89ac2928..f1671b5d 100644 --- a/packages/kb.gbapp/services/KBService.ts +++ b/packages/kb.gbapp/services/KBService.ts @@ -1101,10 +1101,15 @@ export class KBService implements IGBKBService { GBLogEx.info(min, `Vectorizing ${files.length} file(s)...`); - // if (await GBUtil.exists(path.join(min['vectorStorePath'], 'args.json'))){ - // await min['vectorStore'].delete(min['vectorStorePath']); - // } - + if (await GBUtil.exists(min['vectorStorePath'])) { + + GBLogEx.info(min, `Cleaning vector store: ${min['vectorStorePath']}...`) + const gbkbPath = GBUtil.getGBAIPath(min.botId, 'gbkb'); + min['vectorStorePath'] = path.join('work', gbkbPath, 'docs-vectorized'); + min['vectorStore'] = await min.deployService.loadOrCreateEmptyVectorStore(min); + + } + await CollectionUtil.asyncForEach(files, async file => { let content = null;