@langchain/core
Version:
Core LangChain.js abstractions and schemas
1 lines • 6.09 kB
Source Map (JSON)
{"version":3,"file":"vectorstores.d.ts","names":["Document","EmbeddingsInterface","VectorStore","cosine","MemoryVector","Record","FakeVectorStoreArgs","FakeVectorStore","similarity","Promise"],"sources":["../../../src/utils/testing/vectorstores.d.ts"],"sourcesContent":["import { Document } from \"../../documents/document.js\";\nimport { EmbeddingsInterface } from \"../../embeddings.js\";\nimport { VectorStore } from \"../../vectorstores.js\";\nimport { cosine } from \"../ml-distance/similarities.js\";\n/**\n * Interface representing a vector in memory. It includes the content\n * (text), the corresponding embedding (vector), and any associated\n * metadata.\n */\ninterface MemoryVector {\n content: string;\n embedding: number[];\n metadata: Record<string, any>;\n}\n/**\n * Interface for the arguments that can be passed to the\n * `FakeVectorStore` constructor. It includes an optional `similarity`\n * function.\n */\nexport interface FakeVectorStoreArgs {\n similarity?: typeof cosine;\n}\n/**\n * Class that extends `VectorStore` to store vectors in memory. Provides\n * methods for adding documents, performing similarity searches, and\n * creating instances from texts, documents, or an existing index.\n */\nexport declare class FakeVectorStore extends VectorStore {\n FilterType: (doc: Document) => boolean;\n memoryVectors: MemoryVector[];\n similarity: typeof cosine;\n _vectorstoreType(): string;\n constructor(embeddings: EmbeddingsInterface, { similarity, ...rest }?: FakeVectorStoreArgs);\n /**\n * Method to add documents to the memory vector store. It extracts the\n * text from each document, generates embeddings for them, and adds the\n * resulting vectors to the store.\n * @param documents Array of `Document` instances to be added to the store.\n * @returns Promise that resolves when all documents have been added.\n */\n addDocuments(documents: Document[]): Promise<void>;\n /**\n * Method to add vectors to the memory vector store. It creates\n * `MemoryVector` instances for each vector and document pair and adds\n * them to the store.\n * @param vectors Array of vectors to be added to the store.\n * @param documents Array of `Document` instances corresponding to the vectors.\n * @returns Promise that resolves when all vectors have been added.\n */\n addVectors(vectors: number[][], documents: Document[]): Promise<void>;\n /**\n * Method to perform a similarity search in the memory vector store. It\n * calculates the similarity between the query vector and each vector in\n * the store, sorts the results by similarity, and returns the top `k`\n * results along with their scores.\n * @param query Query vector to compare against the vectors in the store.\n * @param k Number of top results to return.\n * @param filter Optional filter function to apply to the vectors before performing the search.\n * @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.\n */\n similaritySearchVectorWithScore(query: number[], k: number, filter?: this[\"FilterType\"]): Promise<[Document, number][]>;\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * texts. It creates a `Document` for each text and metadata pair, and\n * adds them to the store.\n * @param texts Array of texts to be added to the store.\n * @param metadatas Array or single object of metadata corresponding to the texts.\n * @param embeddings `Embeddings` instance used to generate embeddings for the texts.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * `Document` instances. It adds the documents to the store.\n * @param docs Array of `Document` instances to be added to the store.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;\n /**\n * Static method to create a `FakeVectorStore` instance from an existing\n * index. It creates a new `FakeVectorStore` instance without adding any\n * documents or vectors.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static fromExistingIndex(embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;\n}\nexport {};\n//# sourceMappingURL=vectorstores.d.ts.map"],"mappings":";;;;;;;;;AAGwD;AAgBxD;AAQA;UAlBUI,YAAAA,CAmBYJ;EACHI,OAAAA,EAAAA,MAAAA;EACID,SAAAA,EAAAA,MAAAA,EAAAA;EAEKF,QAAAA,EApBdI,MAoBcJ,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA;;;;;;;AA4B2ED,UAzCtFM,mBAAAA,CAyCsFN;EAATS,UAAAA,CAAAA,EAAAA,OAxCtEN,MAwCsEM;;;;;;;AAoBPH,cArDlEC,eAAAA,SAAwBL,WAAAA,CAqD0CI;EAA8BC,UAAAA,EAAAA,CAAAA,GAAAA,EApD/FP,QAoD+FO,EAAAA,GAAAA,OAAAA;EAARE,aAAAA,EAnD1FL,YAmD0FK,EAAAA;EASpER,UAAAA,EAAAA,OA3DlBE,MA2DkBF;EAAgCK,gBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAA8BC,WAAAA,CAAAA,UAAAA,EAzD3EN,mBAyD2EM,EAAAA;IAAAA,UAAAA;IAAAA,GAAAA;EAAAA,CAAAA,CAAAA,EAzD5BD,mBAyD4BC;EAARE;;AA9DvC;;;;;0BAa5BT,aAAaS;;;;;;;;;6CASMT,aAAaS;;;;;;;;;;;4FAWkCA,SAAST;;;;;;;;;;;8EAWvBC,gCAAgCK,sBAAsBG,QAAQF;;;;;;;;;6BAS/GP,wBAAwBC,gCAAgCK,sBAAsBG,QAAQF;;;;;;;;;uCAS5EN,gCAAgCK,sBAAsBG,QAAQF"}