/** * Graph RAG - Graph-based Retrieval Augmented Generation * Inspired by mastra's graph-rag module */ export interface GraphNode { id: string; type: string; content: string; metadata?: Record; embedding?: number[]; } export interface GraphEdge { id: string; source: string; target: string; type: string; weight?: number; metadata?: Record; } export interface GraphQueryResult { nodes: GraphNode[]; edges: GraphEdge[]; paths: GraphNode[][]; score: number; } export interface GraphRAGConfig { maxDepth?: number; maxNodes?: number; minScore?: number; includeEdges?: boolean; } /** * In-memory Graph Store for Graph RAG */ export declare class GraphStore { private nodes; private edges; private adjacencyList; private reverseAdjacencyList; /** * Add a node to the graph */ addNode(node: GraphNode): void; /** * Add an edge to the graph */ addEdge(edge: GraphEdge): void; /** * Get a node by ID */ getNode(id: string): GraphNode | undefined; /** * Get all nodes */ getAllNodes(): GraphNode[]; /** * Get neighbors of a node */ getNeighbors(nodeId: string, direction?: 'outgoing' | 'incoming' | 'both'): GraphNode[]; /** * Get edges between two nodes */ getEdgesBetween(sourceId: string, targetId: string): GraphEdge[]; /** * Find paths between two nodes using BFS */ findPaths(startId: string, endId: string, maxDepth?: number): GraphNode[][]; /** * Get subgraph around a node */ getSubgraph(nodeId: string, depth?: number): { nodes: GraphNode[]; edges: GraphEdge[]; }; /** * Clear the graph */ clear(): void; /** * Get graph statistics */ getStats(): { nodeCount: number; edgeCount: number; }; } /** * Graph RAG - Combines graph traversal with vector similarity */ export declare class GraphRAG { private graphStore; private embedFn?; constructor(config?: { embedFn?: (text: string) => Promise; }); /** * Add a document as a node */ addDocument(doc: { id: string; content: string; type?: string; metadata?: Record; }): Promise; /** * Add a relationship between documents */ addRelationship(sourceId: string, targetId: string, type: string, weight?: number): void; /** * Query the graph with a natural language query */ query(query: string, config?: GraphRAGConfig): Promise; /** * Get context string from query results */ getContext(result: GraphQueryResult): string; /** * Get the underlying graph store */ getGraphStore(): GraphStore; private cosineSimilarity; } export declare function createGraphRAG(config?: { embedFn?: (text: string) => Promise; }): GraphRAG;