From 890743ebd019b517c96d5b8757a5252a38aac686 Mon Sep 17 00:00:00 2001 From: Phil Kuang Date: Wed, 25 Sep 2024 11:25:19 -0400 Subject: [PATCH] fix(rag-ai): properly clean up old techdoc vectors --- .changeset/sweet-elephants-glow.md | 5 +++++ .../indexing/DefaultVectorAugmentationIndexer.ts | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 .changeset/sweet-elephants-glow.md diff --git a/.changeset/sweet-elephants-glow.md b/.changeset/sweet-elephants-glow.md new file mode 100644 index 000000000..82ced562f --- /dev/null +++ b/.changeset/sweet-elephants-glow.md @@ -0,0 +1,5 @@ +--- +'@roadiehq/rag-ai-backend-retrieval-augmenter': patch +--- + +Fix issue with cleaning up old TechDocs vectors diff --git a/plugins/backend/rag-ai-backend-retrieval-augmenter/src/indexing/DefaultVectorAugmentationIndexer.ts b/plugins/backend/rag-ai-backend-retrieval-augmenter/src/indexing/DefaultVectorAugmentationIndexer.ts index f3d7ed518..f805b346e 100644 --- a/plugins/backend/rag-ai-backend-retrieval-augmenter/src/indexing/DefaultVectorAugmentationIndexer.ts +++ b/plugins/backend/rag-ai-backend-retrieval-augmenter/src/indexing/DefaultVectorAugmentationIndexer.ts @@ -37,6 +37,10 @@ import { } from '@backstage/backend-plugin-api'; import pLimit from 'p-limit'; +const TECHDOCS_ENTITY_FILTER = { + 'metadata.annotations.backstage.io/techdocs-ref': CATALOG_FILTER_EXISTS, +}; + export class DefaultVectorAugmentationIndexer implements AugmentationIndexer { private readonly _vectorStore: RoadieVectorStore; private readonly catalogApi: CatalogApi; @@ -184,10 +188,7 @@ export class DefaultVectorAugmentationIndexer implements AugmentationIndexer { const entitiesResponse = await this.catalogApi.getEntities( { - filter: { - 'metadata.annotations.backstage.io/techdocs-ref': - CATALOG_FILTER_EXISTS, - }, + filter: TECHDOCS_ENTITY_FILTER, }, { token }, ); @@ -273,8 +274,10 @@ export class DefaultVectorAugmentationIndexer implements AugmentationIndexer { targetPluginId: 'catalog', }); + const entityFilter = + source === 'tech-docs' ? TECHDOCS_ENTITY_FILTER : filter; const entities = ( - await this.catalogApi.getEntities({ filter }, { token }) + await this.catalogApi.getEntities({ filter: entityFilter }, { token }) ).items.map(stringifyEntityRef); for (const entityRef of entities) {