Skip to content

Commit

Permalink
fix(rag-ai): properly clean up old techdoc vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
kuangp committed Sep 25, 2024
1 parent a4043ee commit 890743e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/sweet-elephants-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@roadiehq/rag-ai-backend-retrieval-augmenter': patch
---

Fix issue with cleaning up old TechDocs vectors
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 },
);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 890743e

Please sign in to comment.