@langchain/community
Version:
Third-party integrations for LangChain.js
1 lines • 7.58 kB
Source Map (JSON)
{"version":3,"file":"momento_vector_index.d.ts","names":["IVectorIndexClient","Document","EmbeddingsInterface","MaxMarginalRelevanceSearchOptions","VectorStore","DocumentProps","MomentoVectorIndexLibArgs","DeleteProps","MomentoVectorIndex","Record","Promise"],"sources":["../../src/vectorstores/momento_vector_index.d.ts"],"sourcesContent":["import { IVectorIndexClient } from \"@gomomento/sdk-core\";\nimport { Document } from \"@langchain/core/documents\";\nimport type { EmbeddingsInterface } from \"@langchain/core/embeddings\";\nimport { MaxMarginalRelevanceSearchOptions, VectorStore } from \"@langchain/core/vectorstores\";\nexport interface DocumentProps {\n ids: string[];\n}\nexport interface MomentoVectorIndexLibArgs {\n /**\n * The Momento Vector Index client.\n */\n client: IVectorIndexClient;\n /**\n * The name of the index to use to store the data.\n * Defaults to \"default\".\n */\n indexName?: string;\n /**\n * The name of the metadata field to use to store the text of the document.\n * Defaults to \"text\".\n */\n textField?: string;\n /**\n * Whether to create the index if it does not already exist.\n * Defaults to true.\n */\n ensureIndexExists?: boolean;\n}\nexport interface DeleteProps {\n /**\n * The ids of the documents to delete.\n */\n ids: string[];\n}\n/**\n * A vector store that uses the Momento Vector Index.\n *\n * @remarks\n * To sign up for a free Momento account, visit https://console.gomomento.com.\n */\nexport declare class MomentoVectorIndex extends VectorStore {\n private client;\n private indexName;\n private textField;\n private _ensureIndexExists;\n _vectorstoreType(): string;\n /**\n * Creates a new `MomentoVectorIndex` instance.\n * @param embeddings The embeddings instance to use to generate embeddings from documents.\n * @param args The arguments to use to configure the vector store.\n */\n constructor(embeddings: EmbeddingsInterface, args: MomentoVectorIndexLibArgs);\n /**\n * Returns the Momento Vector Index client.\n * @returns The Momento Vector Index client.\n */\n getClient(): IVectorIndexClient;\n private ensureIndexExists;\n /**\n * Converts the documents to a format that can be stored in the index.\n *\n * This is necessary because the Momento Vector Index requires that the metadata\n * be a map of strings to strings.\n * @param vectors The vectors to convert.\n * @param documents The documents to convert.\n * @param ids The ids to convert.\n * @returns The converted documents.\n */\n private prepareItemBatch;\n /**\n * Adds vectors to the index.\n *\n * @remarks If the index does not already exist, it will be created if `ensureIndexExists` is true.\n * @param vectors The vectors to add to the index.\n * @param documents The documents to add to the index.\n * @param documentProps The properties of the documents to add to the index, specifically the ids.\n * @returns Promise that resolves when the vectors have been added to the index. Also returns the ids of the\n * documents that were added.\n */\n addVectors(vectors: number[][], documents: Document<Record<string, any>>[], documentProps?: DocumentProps): Promise<void | string[]>;\n /**\n * Adds vectors to the index. Generates embeddings from the documents\n * using the `Embeddings` instance passed to the constructor.\n * @param documents Array of `Document` instances to be added to the index.\n * @returns Promise that resolves when the documents have been added to the index.\n */\n addDocuments(documents: Document[], documentProps?: DocumentProps): Promise<void>;\n /**\n * Deletes vectors from the index by id.\n * @param params The parameters to use to delete the vectors, specifically the ids.\n */\n delete(params: DeleteProps): Promise<void>;\n /**\n * Searches the index for the most similar vectors to the query vector.\n * @param query The query vector.\n * @param k The number of results to return.\n * @returns Promise that resolves to the documents of the most similar vectors\n * to the query vector.\n */\n similaritySearchVectorWithScore(query: number[], k: number): Promise<[Document<Record<string, any>>, number][]>;\n /**\n * Return documents selected using the maximal marginal relevance.\n * Maximal marginal relevance optimizes for similarity to the query AND diversity\n * among selected documents.\n *\n * @param {string} query - Text to look up documents similar to.\n * @param {number} options.k - Number of documents to return.\n * @param {number} options.fetchK - Number of documents to fetch before passing to the MMR algorithm.\n * @param {number} options.lambda - Number between 0 and 1 that determines the degree of diversity among the results,\n * where 0 corresponds to maximum diversity and 1 to minimum diversity.\n * @param {this[\"FilterType\"]} options.filter - Optional filter\n * @param _callbacks\n *\n * @returns {Promise<Document[]>} - List of documents selected by maximal marginal relevance.\n */\n maxMarginalRelevanceSearch(query: string, options: MaxMarginalRelevanceSearchOptions<this[\"FilterType\"]>): Promise<Document[]>;\n /**\n * Stores the documents in the index.\n *\n * Converts the documents to vectors using the `Embeddings` instance passed.\n * @param texts The texts to store in the index.\n * @param metadatas The metadata to store in the index.\n * @param embeddings The embeddings instance to use to generate embeddings from the documents.\n * @param dbConfig The configuration to use to instantiate the vector store.\n * @param documentProps The properties of the documents to add to the index, specifically the ids.\n * @returns Promise that resolves to the vector store.\n */\n static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig: MomentoVectorIndexLibArgs, documentProps?: DocumentProps): Promise<MomentoVectorIndex>;\n /**\n * Stores the documents in the index.\n * @param docs The documents to store in the index.\n * @param embeddings The embeddings instance to use to generate embeddings from the documents.\n * @param dbConfig The configuration to use to instantiate the vector store.\n * @param documentProps The properties of the documents to add to the index, specifically the ids.\n * @returns Promise that resolves to the vector store.\n */\n static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig: MomentoVectorIndexLibArgs, documentProps?: DocumentProps): Promise<MomentoVectorIndex>;\n}\n//# sourceMappingURL=momento_vector_index.d.ts.map"],"mappings":";;;;;;UAIiBK,aAAAA;;AAAjB;AAGiBC,UAAAA,yBAAAA,CAAyB;EAqBzBC;AAYjB;;EAWuDD,MAAAA,EAxC3CN,kBAwC2CM;EAKtCN;;;;EAuB+FU,SAAAA,CAAAA,EAAAA,MAAAA;EAOpFT;;;;EAKKS,SAAAA,CAAAA,EAAAA,MAAAA;EAQkDD;;;;EAgBoCR,iBAAAA,CAAAA,EAAAA,OAAAA;;AAYvCC,UAnG/DK,WAAAA,CAmG+DL;EAA+BI;;;EAA2DI,GAAAA,EAAAA,MAAAA,EAAAA;;;;;;;;AAvF/G,cAAtCF,kBAAAA,SAA2BJ,WAAAA,CAAW;;;;;;;;;;;0BAW/BF,2BAA2BI;;;;;eAKtCN;;;;;;;;;;;;;;;;;;;;;;;6CAuB8BC,SAASQ,wCAAwCJ,gBAAgBK;;;;;;;0BAOpFT,4BAA4BI,gBAAgBK;;;;;iBAKrDH,cAAcG;;;;;;;;+DAQgCA,SAAST,SAASQ;;;;;;;;;;;;;;;;qDAgB5BN,wDAAwDO,QAAQT;;;;;;;;;;;;8EAYvCC,+BAA+BI,2CAA2CD,gBAAgBK,QAAQF;;;;;;;;;6BASnJP,wBAAwBC,+BAA+BI,2CAA2CD,gBAAgBK,QAAQF"}