{"version":3,"file":"hnswlib.d.cts","names":["HierarchicalNSW","HierarchicalNSWT","SpaceName","EmbeddingsInterface","SaveableVectorStore","Document","SynchronousInMemoryDocstore","HNSWLibBase","HNSWLibArgs","HNSWLib","Promise","Record"],"sources":["../../src/vectorstores/hnswlib.d.ts"],"sourcesContent":["import type { HierarchicalNSW as HierarchicalNSWT, SpaceName } from \"hnswlib-node\";\nimport type { EmbeddingsInterface } from \"@langchain/core/embeddings\";\nimport { SaveableVectorStore } from \"@langchain/core/vectorstores\";\nimport { Document } from \"@langchain/core/documents\";\nimport { SynchronousInMemoryDocstore } from \"../stores/doc/in_memory.js\";\n/**\n * Interface for the base configuration of HNSWLib. It includes the space\n * name and the number of dimensions.\n */\nexport interface HNSWLibBase {\n    space: SpaceName;\n    numDimensions?: number;\n}\n/**\n * Interface for the arguments that can be passed to the HNSWLib\n * constructor. It extends HNSWLibBase and includes properties for the\n * document store and HNSW index.\n */\nexport interface HNSWLibArgs extends HNSWLibBase {\n    docstore?: SynchronousInMemoryDocstore;\n    index?: HierarchicalNSWT;\n}\n/**\n * Class that implements a vector store using Hierarchical Navigable Small\n * World (HNSW) graphs. It extends the SaveableVectorStore class and\n * provides methods for adding documents and vectors, performing\n * similarity searches, and saving and loading the vector store.\n */\nexport declare class HNSWLib extends SaveableVectorStore {\n    FilterType: (doc: Document) => boolean;\n    _index?: HierarchicalNSWT;\n    docstore: SynchronousInMemoryDocstore;\n    args: HNSWLibBase;\n    _vectorstoreType(): string;\n    constructor(embeddings: EmbeddingsInterface, args: HNSWLibArgs);\n    /**\n     * Method to add documents to the vector store. It first converts the\n     * documents to vectors using the embeddings, then adds the vectors to the\n     * vector store.\n     * @param documents The documents to be added to the vector store.\n     * @returns A Promise that resolves when the documents have been added.\n     */\n    addDocuments(documents: Document[]): Promise<void>;\n    private static getHierarchicalNSW;\n    private initIndex;\n    get index(): HierarchicalNSWT;\n    private set index(value);\n    /**\n     * Method to add vectors to the vector store. It first initializes the\n     * index if it hasn't been initialized yet, then adds the vectors to the\n     * index and the documents to the document store.\n     * @param vectors The vectors to be added to the vector store.\n     * @param documents The documents corresponding to the vectors.\n     * @returns A Promise that resolves when the vectors and documents have been added.\n     */\n    addVectors(vectors: number[][], documents: Document[]): Promise<void>;\n    /**\n     * Method to perform a similarity search in the vector store using a query\n     * vector. It returns the k most similar documents along with their\n     * similarity scores. An optional filter function can be provided to\n     * filter the documents.\n     * @param query The query vector.\n     * @param k The number of most similar documents to return.\n     * @param filter An optional filter function to filter the documents.\n     * @returns A Promise that resolves to an array of tuples, where each tuple contains a document and its similarity score.\n     */\n    similaritySearchVectorWithScore(query: number[], k: number, filter?: this[\"FilterType\"]): Promise<[Document<Record<string, any>>, number][]>;\n    /**\n     * Method to delete the vector store from a directory. It deletes the\n     * hnswlib.index file, the docstore.json file, and the args.json file from\n     * the directory.\n     * @param params An object with a directory property that specifies the directory from which to delete the vector store.\n     * @returns A Promise that resolves when the vector store has been deleted.\n     */\n    delete(params: {\n        directory: string;\n    }): Promise<void>;\n    /**\n     * Method to save the vector store to a directory. It saves the HNSW\n     * index, the arguments, and the document store to the directory.\n     * @param directory The directory to which to save the vector store.\n     * @returns A Promise that resolves when the vector store has been saved.\n     */\n    save(directory: string): Promise<void>;\n    /**\n     * Static method to load a vector store from a directory. It reads the\n     * HNSW index, the arguments, and the document store from the directory,\n     * then creates a new HNSWLib instance with these values.\n     * @param directory The directory from which to load the vector store.\n     * @param embeddings The embeddings to be used by the HNSWLib instance.\n     * @returns A Promise that resolves to a new HNSWLib instance.\n     */\n    static load(directory: string, embeddings: EmbeddingsInterface): Promise<HNSWLib>;\n    /**\n     * Static method to create a new HNSWLib instance from texts and metadata.\n     * It creates a new Document instance for each text and metadata, then\n     * calls the fromDocuments method to create the HNSWLib instance.\n     * @param texts The texts to be used to create the documents.\n     * @param metadatas The metadata to be used to create the documents.\n     * @param embeddings The embeddings to be used by the HNSWLib instance.\n     * @param dbConfig An optional configuration object for the document store.\n     * @returns A Promise that resolves to a new HNSWLib instance.\n     */\n    static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig?: {\n        docstore?: SynchronousInMemoryDocstore;\n    }): Promise<HNSWLib>;\n    /**\n     * Static method to create a new HNSWLib instance from documents. It\n     * creates a new HNSWLib instance, adds the documents to it, then returns\n     * the instance.\n     * @param docs The documents to be added to the HNSWLib instance.\n     * @param embeddings The embeddings to be used by the HNSWLib instance.\n     * @param dbConfig An optional configuration object for the document store.\n     * @returns A Promise that resolves to a new HNSWLib instance.\n     */\n    static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig?: {\n        docstore?: SynchronousInMemoryDocstore;\n    }): Promise<HNSWLib>;\n    static imports(): Promise<{\n        HierarchicalNSW: typeof HierarchicalNSWT;\n    }>;\n}\n//# sourceMappingURL=hnswlib.d.ts.map"],"mappings":";;;;;;;;;;AASA;AASA;AACeM,UAVEC,WAAAA,CAUFD;EACHL,KAAAA,EAVDC,SAUCD;EAFyBM,aAAAA,CAAAA,EAAAA,MAAAA;AAAW;AAUhD;;;;;AAM4BJ,UAhBXK,WAAAA,SAAoBD,WAgBTJ,CAAAA;EAA2BK,QAAAA,CAAAA,EAfxCF,mBAAAA,CAAAA,2BAewCE;EAQ3BH,KAAAA,CAAAA,EAtBhBJ,eAsBgBI;;;;;;;;AAkCpBK,cAhDaD,OAAAA,SAAgBL,mBAAAA,CAgD7BM;EAOqBA,UAAAA,EAAAA,CAAAA,GAAAA,EAtDPL,QAsDOK,EAAAA,GAAAA,OAAAA;EASkBP,MAAAA,CAAAA,EA9DlCF,eA8DkCE;EAA8BM,QAAAA,EA7D/DH,mBAAAA,CAAAA,2BA6D+DG;EAARC,IAAAA,EA5D3DH,WA4D2DG;EAWWP,gBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAC7DG,WAAAA,CAAAA,UAAAA,EAtESH,mBAsETG,EAAAA,IAAAA,EAtEoCE,WAsEpCF;EACHG;;;;;;;EAcgBR,YAAAA,CAAAA,S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