@langchain/community
Version:
Third-party integrations for LangChain.js
1 lines • 5.59 kB
Source Map (JSON)
{"version":3,"file":"common.d.cts","names":["CloseVectorSaveableVectorStore","EmbeddingsInterface","Document","SaveableVectorStore","CloseVectorCredentials","CloseVector","CloseVectorHNSWImplementation","Promise","Record"],"sources":["../../../src/vectorstores/closevector/common.d.ts"],"sourcesContent":["import type { CloseVectorSaveableVectorStore } from \"closevector-common\";\nimport type { EmbeddingsInterface } from \"@langchain/core/embeddings\";\nimport { Document } from \"@langchain/core/documents\";\nimport { SaveableVectorStore } from \"@langchain/core/vectorstores\";\ntype CloseVectorCredentials = {\n key?: string;\n secret?: string;\n};\n/**\n * package closevector is largely based on hnswlib.ts in the current folder with the following exceptions:\n * 1. It uses a modified version of hnswlib-node to ensure the generated index can be loaded by closevector_web.ts.\n * 2. It adds features to upload and download the index to/from the CDN provided by CloseVector.\n *\n * For more information, check out https://closevector-docs.getmegaportal.com/\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 abstract class CloseVector<CloseVectorHNSWImplementation extends CloseVectorSaveableVectorStore> extends SaveableVectorStore {\n FilterType: (doc: Document) => boolean;\n _instance?: CloseVectorHNSWImplementation;\n credentials?: CloseVectorCredentials;\n _vectorstoreType(): string;\n constructor(embeddings: EmbeddingsInterface, args: {\n space: \"l2\" | \"ip\" | \"cosine\";\n numDimensions?: number;\n maxElements?: number;\n }, credentials?: CloseVectorCredentials);\n get instance(): CloseVectorHNSWImplementation;\n protected set instance(instance: CloseVectorHNSWImplementation);\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 abstract saveToCloud(_options: Record<string, unknown>): 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. In CloseVector, we use IndexedDB to mock the file system. Therefore, this parameter is can be treated as a key to the contents stored.\n * @returns A Promise that resolves when the vector store has been saved.\n */\n save(directory: string): Promise<void>;\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, unknown>>, 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 static textsToDocuments(texts: string[], metadatas: object[] | object): Document<Record<string, any>>[];\n}\nexport {};\n//# sourceMappingURL=common.d.ts.map"],"mappings":";;;;;;KAIKI,sBAAAA;;EAAAA,MAAAA,CAAAA,EAAAA,MAAAA;AAiBL,CAAA;;;;;;;;;;;;;;AAoC+CF,uBApCjBG,WAoCiBH,CAAAA,sCApCiCF,8BAoCjCE,CAAAA,SApCyEC,mBAAAA,CAoCzED;EAAaK,UAAAA,EAAAA,CAAAA,GAAAA,EAnCtCL,QAmCsCK,EAAAA,GAAAA,OAAAA;EAWoDC,SAAAA,CAAAA,EA7ChGF,6BA6CgGE;EAATN,WAAAA,CAAAA,EA5CrFE,sBA4CqFF;EAATK,gBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAUtFA,WAAAA,CAAAA,UAAAA,EApDoBN,mBAoDpBM,EAAAA,IAAAA,EAAAA;IAC6EC,KAAAA,EAAAA,IAAAA,GAAAA,IAAAA,GAAAA,QAAAA;IAATN,aAAAA,CAAAA,EAAAA,MAAAA;IA1D4CC,WAAAA,CAAAA,EAAAA,MAAAA;EAAmB,CAAA,EAAA,WAAA,CAAA,EAStHC,sBATsH;kBAUvHE;mCACiBA;;;;;;;;0BAQTJ,aAAaK;iCACNC,0BAA0BD;;;;;;;2BAOhCA;;;;;;;;;6CASkBL,aAAaK;;;;;;;;;;;4FAWkCA,SAASL,SAASM;;;;;;;;;;MAUxGD;0EACoEL,SAASM"}