import { Document, Filter, MongoClient } from "mongodb"; import { MaxMarginalRelevanceSearchOptions, VectorStore } from "@langchain/core/vectorstores"; import { Document as Document$1, DocumentInterface } from "@langchain/core/documents"; import { EmbeddingsInterface } from "@langchain/core/embeddings"; //#region src/azure_documentdb.d.ts /** Azure DocumentDB Similarity type. */ declare const AzureDocumentDBSimilarityType: { /** Cosine similarity */readonly COS: "COS"; /** Inner - product */ readonly IP: "IP"; /** Euclidian distance */ readonly L2: "L2"; }; /** Azure DocumentDB Similarity type. */ type AzureDocumentDBSimilarityType = (typeof AzureDocumentDBSimilarityType)[keyof typeof AzureDocumentDBSimilarityType]; /** Azure DocumentDB Index Options. */ type AzureDocumentDBIndexOptions = { /** Skips automatic index creation. */readonly skipCreate?: boolean; readonly indexType?: "ivf" | "hnsw" | "diskann"; /** Number of clusters that the inverted file (IVF) index uses to group the vector data. */ readonly numLists?: number; /** Number of dimensions for vector similarity. */ readonly dimensions?: number; /** Similarity metric to use with the IVF index. */ readonly similarity?: AzureDocumentDBSimilarityType; /** The max number of connections per layer with the HNSW index. */ readonly m?: number; /** The size of the dynamic candidate list for constructing the graph with the HNSW index. */ readonly efConstruction?: number; /** Max number of neighbors with the DiskANN index */ readonly maxDegree?: number; /** L value for index building with the DiskANN index */ readonly lBuild?: number; /** L value for index searching with the DiskANN index */ readonly lSearch?: number; }; /** Azure DocumentDB delete Parameters. */ type AzureDocumentDBDeleteParams = { /** List of IDs for the documents to be removed. */readonly ids?: string | string[]; /** MongoDB filter object or list of IDs for the documents to be removed. */ readonly filter?: Filter; }; /** Configuration options for the `AzureDocumentDBVectorStore` constructor. */ interface AzureDocumentDBConfig { readonly client?: MongoClient; readonly connectionString?: string; readonly databaseName?: string; readonly collectionName?: string; readonly indexName?: string; readonly textKey?: string; readonly embeddingKey?: string; readonly indexOptions?: AzureDocumentDBIndexOptions; } /** * Azure DocumentDB vector store. * To use this, you should have both: * - the `mongodb` NPM package installed * - a connection string associated with an Azure DocumentDB cluster * * You do not need to create a database or collection, it will be created * automatically. * * You also need an index on the collection, which is by default created * automatically using the `createIndex` method. */ declare class AzureDocumentDBVectorStore extends VectorStore { get lc_secrets(): { [key: string]: string; }; private connectPromise; private initPromise?; private readonly client; private database; private collection; readonly indexName: string; readonly textKey: string; readonly embeddingKey: string; private readonly indexOptions; /** * Initializes the AzureDocumentDBVectorStore. * Connect the client to the database and create the container, creating them if needed. * @returns A promise that resolves when the AzureDocumentDBVectorStore has been initialized. */ initialize: () => Promise; _vectorstoreType(): string; constructor(embeddings: EmbeddingsInterface, dbConfig: AzureDocumentDBConfig); /** * Checks if the specified index name during instance construction exists * on the collection. * @returns A promise that resolves to a boolean indicating if the index exists. */ checkIndexExists(): Promise; /** * Deletes the index specified during instance construction if it exists. * @returns A promise that resolves when the index has been deleted. */ deleteIndex(): Promise; /** * Creates an index on the collection with the specified index name during * instance construction. * * Setting the numLists parameter correctly is important for achieving good * accuracy and performance. * Since the vector store uses IVF as the indexing strategy, you should * create the index only after you have loaded a large enough sample * documents to ensure that the centroids for the respective buckets are * fairly distributed. * * We recommend that numLists is set to documentCount/1000 for up to * 1 million documents and to sqrt(documentCount) for more than 1 million * documents. * As the number of items in your database grows, you should tune numLists * to be larger in order to achieve good latency performance for vector * search. * * If you're experimenting with a new scenario or creating a small demo, * you can start with numLists set to 1 to perform a brute-force search * across all vectors. * This should provide you with the most accurate results from the vector * search, however be aware that the search speed and latency will be slow. * After your initial setup, you should go ahead and tune the numLists * parameter using the above guidance. * @param numLists This integer is the number of clusters that the inverted * file (IVF) index uses to group the vector data. * We recommend that numLists is set to documentCount/1000 for up to * 1 million documents and to sqrt(documentCount) for more than 1 million * documents. * Using a numLists value of 1 is akin to performing brute-force search, * which has limited performance * @param indexType Index Type for Azure DocumentDB index. * @param dimensions Number of dimensions for vector similarity. * The maximum number of supported dimensions is 2000. * If no number is provided, it will be determined automatically by * embedding a short text. * @param similarity Similarity metric to use with the IVF index. * Possible options are: * - AzureDocumentDBSimilarityType.COS (cosine distance) * - AzureDocumentDBSimilarityType.L2 (Euclidean distance) * - AzureDocumentDBSimilarityType.IP (inner product) * @returns A promise that resolves when the index has been created. */ createIndex(dimensions?: number | undefined, indexType?: "ivf" | "hnsw" | "diskann", similarity?: AzureDocumentDBSimilarityType): Promise; /** * Removes specified documents from the AzureDocumentDBVectorStore. * If no IDs or filter are specified, all documents will be removed. * @param params Parameters for the delete operation. * @returns A promise that resolves when the documents have been removed. */ delete(params?: AzureDocumentDBDeleteParams | string[]): Promise; /** * Closes any newly instantiated Azure DocumentDB client. * If the client was passed in the constructor, it will not be closed. * @returns A promise that resolves when any newly instantiated Azure * DocumentDB client has been closed. */ close(): Promise; /** * Method for adding vectors to the AzureDocumentDBVectorStore. * @param vectors Vectors to be added. * @param documents Corresponding documents to be added. * @returns A promise that resolves to the added documents IDs. */ addVectors(vectors: number[][], documents: DocumentInterface[]): Promise; /** * Method for adding documents to the AzureDocumentDBVectorStore. It first converts * the documents to texts and then adds them as vectors. * @param documents The documents to add. * @returns A promise that resolves to the added documents IDs. */ addDocuments(documents: DocumentInterface[]): Promise; /** * Method that performs a similarity search on the vectors stored in the * collection. It returns a list of documents and their corresponding * similarity scores. * @param queryVector Query vector for the similarity search. * @param k=4 Number of nearest neighbors to return. * @returns Promise that resolves to a list of documents and their corresponding similarity scores. */ similaritySearchVectorWithScore(queryVector: number[], k: number, indexType?: "ivf" | "hnsw" | "diskann"): Promise<[Document$1, number][]>; /** * Return documents selected using the maximal marginal relevance. * Maximal marginal relevance optimizes for similarity to the query AND * diversity among selected documents. * @param query Text to look up documents similar to. * @param options.k Number of documents to return. * @param options.fetchK=20 Number of documents to fetch before passing to * the MMR algorithm. * @param options.lambda=0.5 Number between 0 and 1 that determines the * degree of diversity among the results, where 0 corresponds to maximum * diversity and 1 to minimum diversity. * @returns List of documents selected by maximal marginal relevance. */ maxMarginalRelevanceSearch(query: string, options: MaxMarginalRelevanceSearchOptions): Promise; maxMarginalRelevanceSearch(query: string, options: MaxMarginalRelevanceSearchOptions, indexType: "ivf" | "hnsw" | "diskann"): Promise; private init; /** * Static method to create an instance of AzureDocumentDBVectorStore from a * list of texts. It first converts the texts to vectors and then adds * them to the collection. * @param texts List of texts to be converted to vectors. * @param metadatas Metadata for the texts. * @param embeddings Embeddings to be used for conversion. * @param dbConfig Database configuration for Azure DocumentDB. * @returns Promise that resolves to a new instance of AzureDocumentDBVectorStore. */ static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig: AzureDocumentDBConfig): Promise; /** * Static method to create an instance of AzureDocumentDBVectorStore from a * list of documents. It first converts the documents to vectors and then * adds them to the collection. * @param docs List of documents to be converted to vectors. * @param embeddings Embeddings to be used for conversion. * @param dbConfig Database configuration for Azure DocumentDB. * @returns Promise that resolves to a new instance of AzureDocumentDBVectorStore. */ static fromDocuments(docs: Document$1[], embeddings: EmbeddingsInterface, dbConfig: AzureDocumentDBConfig): Promise; } /** * @deprecated Use `AzureDocumentDBSimilarityType` instead. This alias will be removed in a future version. */ declare const AzureCosmosDBMongoDBSimilarityType: { /** Cosine similarity */readonly COS: "COS"; /** Inner - product */ readonly IP: "IP"; /** Euclidian distance */ readonly L2: "L2"; }; /** * @deprecated Use `AzureDocumentDBSimilarityType` instead. This alias will be removed in a future version. */ type AzureCosmosDBMongoDBSimilarityType = AzureDocumentDBSimilarityType; /** * @deprecated Use `AzureDocumentDBIndexOptions` instead. This alias will be removed in a future version. */ type AzureCosmosDBMongoDBIndexOptions = AzureDocumentDBIndexOptions; /** * @deprecated Use `AzureDocumentDBDeleteParams` instead. This alias will be removed in a future version. */ type AzureCosmosDBMongoDBDeleteParams = AzureDocumentDBDeleteParams; /** * @deprecated Use `AzureDocumentDBConfig` instead. This alias will be removed in a future version. */ type AzureCosmosDBMongoDBConfig = AzureDocumentDBConfig; /** * @deprecated Use `AzureDocumentDBVectorStore` instead. This alias will be removed in a future version. */ declare const AzureCosmosDBMongoDBVectorStore: typeof AzureDocumentDBVectorStore; /** * @deprecated Use `AzureDocumentDBVectorStore` instead. This alias will be removed in a future version. */ type AzureCosmosDBMongoDBVectorStore = AzureDocumentDBVectorStore; //#endregion export { AzureCosmosDBMongoDBConfig, AzureCosmosDBMongoDBDeleteParams, AzureCosmosDBMongoDBIndexOptions, AzureCosmosDBMongoDBSimilarityType, AzureCosmosDBMongoDBVectorStore, AzureDocumentDBConfig, AzureDocumentDBDeleteParams, AzureDocumentDBIndexOptions, AzureDocumentDBSimilarityType, AzureDocumentDBVectorStore }; //# sourceMappingURL=azure_documentdb.d.ts.map