import type { BaseNode, Document } from "../Node.js"; import type { BaseRetriever } from "../Retriever.js"; import type { ServiceContext } from "../ServiceContext.js"; import type { StorageContext } from "../storage/StorageContext.js"; import type { BaseDocumentStore } from "../storage/docStore/types.js"; import type { BaseIndexStore } from "../storage/indexStore/types.js"; import type { BaseSynthesizer } from "../synthesizers/types.js"; import type { QueryEngine } from "../types.js"; import { IndexStruct } from "./IndexStruct.js"; import { IndexStructType } from "./json-to-index-struct.js"; export declare class KeywordTable extends IndexStruct { table: Map>; type: IndexStructType; addNode(keywords: string[], nodeId: string): void; deleteNode(keywords: string[], nodeId: string): void; toJson(): Record; } export interface BaseIndexInit { serviceContext?: ServiceContext; storageContext: StorageContext; docStore: BaseDocumentStore; indexStore?: BaseIndexStore; indexStruct: T; } /** * Indexes are the data structure that we store our nodes and embeddings in so * they can be retrieved for our queries. */ export declare abstract class BaseIndex { serviceContext?: ServiceContext; storageContext: StorageContext; docStore: BaseDocumentStore; indexStore?: BaseIndexStore; indexStruct: T; constructor(init: BaseIndexInit); /** * Create a new retriever from the index. * @param retrieverOptions */ abstract asRetriever(options?: any): BaseRetriever; /** * Create a new query engine from the index. It will also create a retriever * and response synthezier if they are not provided. * @param options you can supply your own custom Retriever and ResponseSynthesizer */ abstract asQueryEngine(options?: { retriever?: BaseRetriever; responseSynthesizer?: BaseSynthesizer; }): QueryEngine; /** * Insert a document into the index. * @param document */ insert(document: Document): Promise; abstract insertNodes(nodes: BaseNode[]): Promise; abstract deleteRefDoc(refDocId: string, deleteFromDocStore?: boolean): Promise; }