Skip to main content

Class: GraphRAGEngine

Defined in: packages/agentos/src/rag/graphrag/GraphRAGEngine.ts:106

Implements

Constructors

Constructor

new GraphRAGEngine(deps?): GraphRAGEngine

Defined in: packages/agentos/src/rag/graphrag/GraphRAGEngine.ts:130

Parameters

deps?
embeddingManager?

IEmbeddingManager

llmProvider?

LLMProvider

persistenceAdapter?

PersistenceAdapter

vectorStore?

IVectorStore

Returns

GraphRAGEngine

Methods

clear()

clear(): Promise<void>

Defined in: packages/agentos/src/rag/graphrag/GraphRAGEngine.ts:1494

Clear all data

Returns

Promise<void>

Implementation of

IGraphRAGEngine.clear


getCommunities()

getCommunities(level?): Promise<GraphCommunity[]>

Defined in: packages/agentos/src/rag/graphrag/GraphRAGEngine.ts:1467

Get community hierarchy

Parameters

level?

number

Returns

Promise<GraphCommunity[]>

Implementation of

IGraphRAGEngine.getCommunities


getEntities()

getEntities(options?): Promise<GraphEntity[]>

Defined in: packages/agentos/src/rag/graphrag/GraphRAGEngine.ts:1451

Get all entities

Parameters

options?
limit?

number

type?

string

Returns

Promise<GraphEntity[]>

Implementation of

IGraphRAGEngine.getEntities


getRelationships()

getRelationships(entityId): Promise<GraphRelationship[]>

Defined in: packages/agentos/src/rag/graphrag/GraphRAGEngine.ts:1460

Get all relationships for an entity

Parameters

entityId

string

Returns

Promise<GraphRelationship[]>

Implementation of

IGraphRAGEngine.getRelationships


getStats()

getStats(): Promise<{ communityLevels: number; documentsIngested: number; totalCommunities: number; totalEntities: number; totalRelationships: number; }>

Defined in: packages/agentos/src/rag/graphrag/GraphRAGEngine.ts:1476

Get statistics

Returns

Promise<{ communityLevels: number; documentsIngested: number; totalCommunities: number; totalEntities: number; totalRelationships: number; }>

Implementation of

IGraphRAGEngine.getStats


globalSearch()

globalSearch(query, options?): Promise<GlobalSearchResult>

Defined in: packages/agentos/src/rag/graphrag/GraphRAGEngine.ts:1116

Global search: answers broad questions using community summaries. Best for "What are the main themes?" type questions.

Parameters

query

string

options?

GraphRAGSearchOptions

Returns

Promise<GlobalSearchResult>

Implementation of

IGraphRAGEngine.globalSearch


ingestDocuments()

ingestDocuments(documents): Promise<{ communitiesDetected: number; documentsProcessed: number; entitiesExtracted: number; relationshipsExtracted: number; }>

Defined in: packages/agentos/src/rag/graphrag/GraphRAGEngine.ts:264

Ingest documents: extract entities/relationships, build graph, detect communities, generate summaries.

Parameters

documents

object[]

Returns

Promise<{ communitiesDetected: number; documentsProcessed: number; entitiesExtracted: number; relationshipsExtracted: number; }>

Implementation of

IGraphRAGEngine.ingestDocuments


initialize()

initialize(config): Promise<void>

Defined in: packages/agentos/src/rag/graphrag/GraphRAGEngine.ts:198

Initialize the engine with configuration

Parameters

config

GraphRAGConfig

Returns

Promise<void>

Implementation of

IGraphRAGEngine.initialize


localSearch()

localSearch(query, options?): Promise<LocalSearchResult>

Defined in: packages/agentos/src/rag/graphrag/GraphRAGEngine.ts:1287

Local search: finds specific entities and their context. Best for "Tell me about X" type questions.

Parameters

query

string

options?

GraphRAGSearchOptions

Returns

Promise<LocalSearchResult>

Implementation of

IGraphRAGEngine.localSearch


removeDocuments()

removeDocuments(documentIds): Promise<{ communitiesDetected: number; documentsRemoved: number; }>

Defined in: packages/agentos/src/rag/graphrag/GraphRAGEngine.ts:417

Remove one or more previously-ingested documents from the graph.

This subtracts the document's entity/relationship contributions and recomputes communities. It is used to keep GraphRAG in sync when a source document is deleted or moved out of indexed categories.

Parameters

documentIds

string[]

Returns

Promise<{ communitiesDetected: number; documentsRemoved: number; }>

Implementation of

IGraphRAGEngine.removeDocuments


shutdown()

shutdown(): Promise<void>

Defined in: packages/agentos/src/rag/graphrag/GraphRAGEngine.ts:1517

Shutdown and cleanup

Returns

Promise<void>

Implementation of

IGraphRAGEngine.shutdown