Skip to content

Commit

Permalink
Merge pull request #1639 from kuangp/fix/rag-ai/techdoc-vector-cleanup
Browse files Browse the repository at this point in the history
fix(rag-ai): properly clean up old techdoc vectors
  • Loading branch information
Xantier authored Sep 26, 2024
2 parents a4043ee + 890743e commit 69f0581
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 69f0581

Please sign in to comment.