@vectorstores/azure 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,585 @@
1
+ import { SqlQuerySpec, CosmosClient, DatabaseRequest, ContainerRequest, VectorEmbeddingPolicy, IndexingPolicy } from '@azure/cosmos';
2
+ import { BaseReader, Document, BaseNode, BaseVectorStore, VectorStoreBaseParams, MetadataFilters, VectorStoreQuery, VectorStoreQueryResult } from '@vectorstores/core';
3
+ export * from './storage.js';
4
+ import { AzureKeyCredential, SearchIndexClient, SearchClient, LexicalAnalyzerName, KnownVectorSearchCompressionKind, KnownVectorSearchAlgorithmKind, VectorizedQuery } from '@azure/search-documents';
5
+ import { DefaultAzureCredential, ManagedIdentityCredential, TokenCredential } from '@azure/identity';
6
+ import { MongoClient, Collection } from 'mongodb';
7
+
8
+ type SimpleCosmosDBReaderLoaderConfig = {
9
+ /**
10
+ * The name of the database to read.
11
+ */
12
+ databaseName: string;
13
+ /**
14
+ * The name of the container to read.
15
+ */
16
+ containerName: string;
17
+ /**
18
+ * An array of field names to retrieve from each document. Defaults to ["text"].
19
+ */
20
+ fields?: string[];
21
+ /**
22
+ * The separator to join multiple field values. Defaults to an empty string.
23
+ */
24
+ fieldSeparator?: string;
25
+ /**
26
+ * A custom query to filter the documents. Defaults to `SELECT * FROM c`.
27
+ */
28
+ query?: string | SqlQuerySpec;
29
+ /**
30
+ * An optional array of metadata field names. If specified extracts this information as metadata.
31
+ */
32
+ metadataFields?: string[];
33
+ };
34
+ /**
35
+ * Read data from CosmosDB.
36
+ */
37
+ declare class SimpleCosmosDBReader implements BaseReader {
38
+ /**
39
+ * The CosmosDB client.
40
+ */
41
+ private client;
42
+ constructor(client: CosmosClient);
43
+ /**
44
+ * Loads data from a Cosmos DB container
45
+ * @returns {Promise<Document[]>}
46
+ */
47
+ loadData(config: SimpleCosmosDBReaderLoaderConfig): Promise<Document[]>;
48
+ }
49
+
50
+ type R = Record<"id" | "chunk" | "embedding" | "doc_id" | "metadata", unknown>;
51
+ declare const AzureAISearchVectorStoreConfig: {
52
+ ALGORITHM_HNSW_NAME: string;
53
+ ALGORITHM_EXHAUSTIVE_KNN_NAME: string;
54
+ PROFILE_HNSW_NAME: string;
55
+ PROFILE_EXHAUSTIVE_KNN_NAME: string;
56
+ COMPRESSION_TYPE_SCALAR: string;
57
+ COMPRESSION_TYPE_BINARY: string;
58
+ SEMANTIC_CONFIG_NAME: string;
59
+ DEFAULT_MAX_BATCH_SIZE: number;
60
+ DEFAULT_MAX_MB_SIZE: number;
61
+ DEFAULT_USER_AGENT_PREFIX: string;
62
+ DEFAULT_AZURE_API_VERSION: string;
63
+ };
64
+
65
+ /**
66
+ * Enumeration representing the supported index management operations
67
+ */
68
+ declare enum IndexManagement {
69
+ NO_VALIDATION = "NoValidation",
70
+ VALIDATE_INDEX = "ValidateIndex",
71
+ CREATE_IF_NOT_EXISTS = "CreateIfNotExists"
72
+ }
73
+ /**
74
+ * Enumeration representing the supported types for metadata fields in an
75
+ * Azure AI Search Index, corresponds with types supported in a flat
76
+ * metadata dictionary.
77
+ */
78
+ declare enum MetadataIndexFieldType {
79
+ STRING = "Edm.String",
80
+ BOOLEAN = "Edm.Boolean",
81
+ INT32 = "Edm.Int32",
82
+ INT64 = "Edm.Int64",
83
+ DOUBLE = "Edm.Double",
84
+ COLLECTION = "Collection(Edm.String)"
85
+ }
86
+ /**
87
+ * Embeddings and documents are stored in an Azure AI Search index,
88
+ * a merge or upload approach is used when adding embeddings.
89
+ * When adding multiple embeddings the index is updated by this vector store
90
+ * in batches of 10 documents, very large nodes may result in failure due to
91
+ * the batch byte size being exceeded.
92
+ */
93
+ interface AzureAISearchOptions<T extends R> {
94
+ userAgent?: string;
95
+ credential?: AzureKeyCredential | DefaultAzureCredential | ManagedIdentityCredential;
96
+ endpoint?: string;
97
+ key?: string;
98
+ serviceApiVersion?: string;
99
+ indexName?: string;
100
+ indexClient?: SearchIndexClient;
101
+ indexManagement?: IndexManagement;
102
+ searchClient?: SearchClient<T>;
103
+ languageAnalyzer?: LexicalAnalyzerName;
104
+ compressionType?: KnownVectorSearchCompressionKind;
105
+ embeddingDimensionality?: number;
106
+ vectorAlgorithmType?: KnownVectorSearchAlgorithmKind;
107
+ /**
108
+ * Index field storing the id
109
+ */
110
+ idFieldKey?: string | undefined;
111
+ /**
112
+ * Index field storing the node text
113
+ */
114
+ chunkFieldKey?: string | undefined;
115
+ /**
116
+ * Index field storing the embedding vector
117
+ */
118
+ embeddingFieldKey?: string | undefined;
119
+ /**
120
+ * Index field storing node metadata as a json string.
121
+ * Schema is arbitrary, to filter on metadata values they must be stored
122
+ * as separate fields in the index, use filterable_metadata_field_keys
123
+ * to specify the metadata values that should be stored in these filterable fields
124
+ */
125
+ metadataStringFieldKey?: string | undefined;
126
+ /**
127
+ * Index field storing doc_id
128
+ */
129
+ docIdFieldKey?: string | undefined;
130
+ /**
131
+ * List of index fields that should be hidden from the client.
132
+ * This is useful for fields that are not needed for retrieving,
133
+ * but are used for similarity search, like the embedding field.
134
+ */
135
+ hiddenFieldKeys?: string[] | undefined;
136
+ filterableMetadataFieldKeys?: FilterableMetadataFieldKeysType | undefined;
137
+ /**
138
+ * (Optional) function used to map document fields to the AI search index fields
139
+ * If none is specified a default mapping is provided which uses
140
+ * the field keys. The keys in the enriched document are:
141
+ * `["id", "chunk", "embedding", "metadata"]`.
142
+ *
143
+ * The default mapping is:
144
+ * - `"id"` to idFieldKey
145
+ * - `"chunk"` to chunkFieldKey
146
+ * - `"embedding"` to embeddingFieldKey
147
+ * - `"metadata"` to metadataFieldKey
148
+ * @param enrichedDoc The enriched document
149
+ * @param metadata The metadata of the document
150
+ * @returns The mapped index document
151
+ */
152
+ indexMapping?: (enrichedDoc: BaseNode, metadata: Record<string, unknown>) => T;
153
+ }
154
+ type FilterableMetadataFieldKeysType = Array<string> | Map<string, string> | Map<string, [string, MetadataIndexFieldType]>;
155
+ /**
156
+ * Azure AI Search vector store.
157
+ *
158
+ * @example
159
+ ```typescript
160
+ import { DefaultAzureCredential, getBearerTokenProvider} from "@azure/identity";
161
+ import {KnownAnalyzerNames, KnownVectorSearchAlgorithmKind } from "@azure/search-documents";
162
+
163
+ // 1- Setup Azure OpenAI
164
+ const azureADTokenProvider = getBearerTokenProvider(
165
+ new DefaultAzureCredential(),
166
+ "https://cognitiveservices.azure.com/.default",
167
+ );
168
+
169
+ // IMPORTANT: You need to deploy your own embedding model as well as your own chat completion model
170
+ // NOTE: You can use whatever embedding model and language model that is supported by vectorstores
171
+ const azure = {
172
+ azureADTokenProvider,
173
+ deployment: process.env.AZURE_DEPLOYMENT_NAME,
174
+ };
175
+ Settings.llm = new OpenAI({ azure });
176
+ Settings.embedModel = new OpenAIEmbedding({
177
+ model: process.env.EMBEDDING_MODEL,
178
+ azure: {
179
+ ...azure,
180
+ deployment: process.env.EMBEDDING_MODEL,
181
+ },
182
+ });
183
+
184
+ // ---------------------------------------------------------
185
+ // 2- Setup Azure AI Search
186
+ // Define env variables in .env file
187
+ // AZURE_AI_SEARCH_ENDPOINT=
188
+ // AZURE_AI_SEARCH_KEY=
189
+ // AZURE_OPENAI_ENDPOINT=
190
+ // EMBEDDING_MODEL=text-embedding-ada-002
191
+ // AZURE_DEPLOYMENT_NAME=gpt-4
192
+ // AZURE_API_VERSION=2024-09-01-preview
193
+
194
+ // Define index name
195
+ const indexName = "vectorstores-vector-store";
196
+
197
+ // ---------------------------------------------------------
198
+ // 3a- Create Index (if it does not exist)
199
+ // id: Edm.String
200
+ // chunk: Edm.String
201
+ // embedding: Collection(Edm.Single)
202
+ // metadata: Edm.String
203
+ // doc_id: Edm.String
204
+ // author: Edm.String
205
+ // theme: Edm.String
206
+ // director: Edm.String
207
+
208
+ // Define metadata fields with their respective configurations
209
+ const metadataFields = {
210
+ author: "author",
211
+ theme: ["theme", MetadataIndexFieldType.STRING],
212
+ director: "director",
213
+ };
214
+
215
+ // Define index parameters and vector store configuration
216
+ // Index validation:
217
+ // - IndexManagement.VALIDATE_INDEX: will validate before creating emnbedding index and will throw a runtime error if the index does not exist
218
+ // - IndexManagement.NO_VALIDATION: will try to access the index and will throw a runtime error if the index does not exist
219
+ // - IndexManagement.CREATE_IF_NOT_EXISTS: will create the index if it does not exist
220
+
221
+ const vectorStore = new AzureAISearchVectorStore({
222
+ filterableMetadataFieldKeys:
223
+ metadataFields as unknown as FilterableMetadataFieldKeysType,
224
+ indexName,
225
+ indexManagement: IndexManagement.CREATE_IF_NOT_EXISTS,
226
+ idFieldKey: "id",
227
+ chunkFieldKey: "chunk",
228
+ embeddingFieldKey: "embedding",
229
+ metadataStringFieldKey: "metadata",
230
+ docIdFieldKey: "doc_id",
231
+ embeddingDimensionality: 1536,
232
+ hiddenFieldKeys: ["embedding"],
233
+ languageAnalyzer: KnownAnalyzerNames.EnLucene,
234
+ // store vectors on disk
235
+ vectorAlgorithmType: KnownVectorSearchAlgorithmKind.ExhaustiveKnn,
236
+
237
+ // Optional: Set to "scalar" or "binary" if using HNSW
238
+ compressionType: KnownVectorSearchCompressionKind.BinaryQuantization,
239
+ });
240
+
241
+ // ---------------------------------------------------------
242
+ // 3a- Loading documents
243
+ // Load the documents stored in the data/paul_graham/ using the SimpleDirectoryReader
244
+ // NOTE: You can use whatever reader that is supported by vectorstores
245
+
246
+ // Load documents using a directory reader
247
+ const documents = await new SimpleDirectoryReader().loadData(
248
+ "data/paul_graham/",
249
+ );
250
+ const storageContext = await storageContextFromDefaults({ vectorStore });
251
+
252
+ // Create index from documents with the specified storage context
253
+ const index = await VectorStoreIndex.fromDocuments(documents, {
254
+ storageContext,
255
+ docStoreStrategy: DocStoreStrategy.UPSERTS,
256
+ });
257
+
258
+ const queryEngine = index.asQueryEngine();
259
+ const response = await queryEngine.query({
260
+ query: "What did the author do growing up?",
261
+ similarityTopK: 3,
262
+ } as any);
263
+ console.log({ response });
264
+ */
265
+ declare class AzureAISearchVectorStore<T extends R> extends BaseVectorStore {
266
+ #private;
267
+ storesText: boolean;
268
+ _searchClient: SearchClient<T> | undefined;
269
+ _indexClient: SearchIndexClient | undefined;
270
+ flatMetadata: boolean;
271
+ constructor(options: AzureAISearchOptions<T> & VectorStoreBaseParams);
272
+ createSearchIndexClient(options: AzureAISearchOptions<T>): void;
273
+ createSearchClient(options: AzureAISearchOptions<T>): void;
274
+ /**
275
+ * Get search client
276
+ * @returns Azure AI Search client. See {@link SearchClient}
277
+ */
278
+ client(): SearchClient<T> | undefined;
279
+ /**
280
+ * Get index client
281
+ * @returns Azure AI Search index client. See {@link SearchIndexClient}
282
+ */
283
+ indexClient(): SearchIndexClient | undefined;
284
+ /**
285
+ * Add nodes to index associated with the configured search client.
286
+ * @param nodes List of nodes with embeddings to add to the index
287
+ * @returns List of node IDs that were added to the index
288
+ */
289
+ add(nodes: BaseNode[]): Promise<string[]>;
290
+ /**
291
+ * Delete documents from the AI Search Index with docIdFieldKey (doc_id) field equal to refDocId.
292
+ * @param refDocId The reference document ID to delete from the index
293
+ */
294
+ delete(refDocId: string): Promise<void>;
295
+ /**
296
+ * Get nodes asynchronously from the Azure AI Search index.
297
+ * @param nodeIds List of node IDs to retrieve from the index
298
+ * @param filters Metadata filters to apply to the search
299
+ * @param limit Maximum number of nodes to retrieve
300
+ * @returns List of nodes retrieved from the index
301
+ */
302
+ getNodes(nodeIds?: string[], filters?: MetadataFilters, limit?: number): Promise<BaseNode[]>;
303
+ query(query: VectorStoreQuery & {
304
+ queryStr: string;
305
+ }): Promise<VectorStoreQueryResult>;
306
+ }
307
+
308
+ /** Azure Cosmos DB for MongoDB vCore Similarity type. */
309
+ declare const AzureCosmosDBMongoDBSimilarityType: {
310
+ /** Cosine similarity */
311
+ readonly COS: "COS";
312
+ /** Inner - product */
313
+ readonly IP: "IP";
314
+ /** Euclidian distance */
315
+ readonly L2: "L2";
316
+ };
317
+ /** Azure Cosmos DB for MongoDB vCore Similarity type. */
318
+ type AzureCosmosDBMongoDBSimilarityType = (typeof AzureCosmosDBMongoDBSimilarityType)[keyof typeof AzureCosmosDBMongoDBSimilarityType];
319
+ /** Azure Cosmos DB for MongoDB vCore Index Options. */
320
+ type AzureCosmosDBMongoDBIndexOptions = {
321
+ readonly indexType?: "ivf" | "hnsw" | "diskann" | undefined;
322
+ /** Number of clusters that the inverted file (IVF) index uses to group the vector data. */
323
+ readonly numLists?: number | undefined;
324
+ /** Number of dimensions for vector similarity. */
325
+ readonly dimensions?: number | undefined;
326
+ /** Similarity metric to use with the IVF index. */
327
+ readonly similarity?: AzureCosmosDBMongoDBSimilarityType | undefined;
328
+ /** The max number of connections per layer with the HNSW index. */
329
+ readonly m?: number | undefined;
330
+ /** The size of the dynamic candidate list for constructing the graph with the HNSW index. */
331
+ readonly efConstruction?: number | undefined;
332
+ /** Max number of neighbors withe the Diskann idnex */
333
+ readonly maxDegree?: number | undefined;
334
+ /** L value for index building withe the Diskann idnex */
335
+ readonly lBuild?: number | undefined;
336
+ /** Compression value for type of vector index compression */
337
+ readonly compression?: "half" | "pq" | undefined;
338
+ /** PqCompressedDims value for dimensions after PQ compression */
339
+ readonly pqCompressedDims?: number | undefined;
340
+ /** PqSampleSize value for number of sample vectors for PQ centroid training */
341
+ readonly pqSampleSize?: number | undefined;
342
+ };
343
+ /** Azure Cosmos DB for MongoDB vCore Query Options. */
344
+ interface AzureCosmosDBMongoDBQueryOptions {
345
+ /** Specifies the size of the dynamic candidate list for search. Used for DiskANN */
346
+ lSearch?: number;
347
+ /** The size of the dynamic candidate list for search (40 by default). Used for HNSW */
348
+ efSearch?: number;
349
+ /** Oversampling specifies how many more candidate vectors to retrieve from the compressed index than k */
350
+ oversampling?: number;
351
+ }
352
+ /**
353
+ * Azure Cosmos DB for MongoDB vCore vector store.
354
+ * To use this, you should have both:
355
+ * - the `mongodb` NPM package installed
356
+ * - a connection string associated with a MongoDB VCore Cluster
357
+ *
358
+ * You do not need to create a database or collection, it will be created
359
+ * automatically.
360
+ *
361
+ * You also need an index on the collection, which is by default be created
362
+ * automatically using the `createIndex` method.
363
+ */
364
+ declare class AzureCosmosDBMongoDBVectorStore extends BaseVectorStore {
365
+ storesText: boolean;
366
+ flatMetadata: boolean;
367
+ dbName: string;
368
+ collectionName: string;
369
+ indexedMetadataFields: string[];
370
+ /**
371
+ * The used MongoClient. If not given, a new MongoClient is created based on the MONGODB_URI env variable.
372
+ */
373
+ mongodbClient: MongoClient;
374
+ indexName: string;
375
+ embeddingKey: string;
376
+ idKey: string;
377
+ textKey: string;
378
+ metadataKey: string;
379
+ indexOptions: AzureCosmosDBMongoDBIndexOptions;
380
+ private collection?;
381
+ private database;
382
+ constructor(init: Partial<AzureCosmosDBMongoDBVectorStore> & {
383
+ dbName: string;
384
+ collectionName: string;
385
+ indexedMetadataFields?: string[];
386
+ } & VectorStoreBaseParams);
387
+ client(): MongoClient;
388
+ ensureCollection(): Promise<Collection>;
389
+ add(nodes: BaseNode[]): Promise<string[]>;
390
+ /**
391
+ * Removes specified documents from the AzureCosmosDBMongoDBVectorStore.
392
+ * @param params Parameters for the delete operation.
393
+ * @returns A promise that resolves when the documents have been removed.
394
+ */
395
+ delete(id: string, deleteOptions?: object): Promise<void>;
396
+ query(query: VectorStoreQuery, options: AzureCosmosDBMongoDBQueryOptions): Promise<VectorStoreQueryResult>;
397
+ /**
398
+ * Creates an index on the collection with the specified index name during
399
+ * instance construction.
400
+ *
401
+ * Setting the numLists parameter correctly is important for achieving good
402
+ * accuracy and performance.
403
+ * Since the vector store uses IVF as the indexing strategy, you should
404
+ * create the index only after you have loaded a large enough sample
405
+ * documents to ensure that the centroids for the respective buckets are
406
+ * faily distributed.
407
+ *
408
+ * As for the compression, the following options are available:
409
+ * - "half" - half precision compression for HNSW and IVF indexes
410
+ * - "pq" - product quantization compression for DiskANN indexes
411
+ * More information on the compression options can be found in the:
412
+ * https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/product-quantization
413
+ *
414
+ * @param indexType Index Type for Mongo vCore index.
415
+ * @param dimensions Number of dimensions for vector similarity.
416
+ * The maximum number of supported dimensions is 2000.
417
+ * If no number is provided, it will be determined automatically by
418
+ * embedding a short text.
419
+ * @param similarity Similarity metric to use with the IVF index.
420
+ * Possible options are:
421
+ * - CosmosDBSimilarityType.COS (cosine distance)
422
+ * - CosmosDBSimilarityType.L2 (Euclidean distance)
423
+ * - CosmosDBSimilarityType.IP (inner product)
424
+ * @returns A promise that resolves when the index has been created.
425
+ */
426
+ createIndex(dimensions?: number | undefined, indexType?: "ivf" | "hnsw" | "diskann", similarity?: AzureCosmosDBMongoDBSimilarityType): Promise<void>;
427
+ /**
428
+ * Checks if the specified index name during instance construction exists
429
+ * on the collection.
430
+ * @returns A promise that resolves to a boolean indicating if the index exists.
431
+ */
432
+ checkIndexExists(): Promise<boolean>;
433
+ /**
434
+ * Deletes the index specified during instance construction if it exists.
435
+ * @returns A promise that resolves when the index has been deleted.
436
+ */
437
+ deleteIndex(indexName: string): Promise<void>;
438
+ }
439
+
440
+ /** Azure Cosmos DB for NoSQL database creation options. */
441
+ type AzureCosmosDBNoSqlCreateDatabaseOptions = Partial<Omit<DatabaseRequest, "id">>;
442
+ /** Azure Cosmos DB for NoSQL container creation options. */
443
+ type AzureCosmosDBNoSqlCreateContainerOptions = Partial<Omit<ContainerRequest, "id" | "vectorEmbeddingPolicy" | "indexingPolicy">>;
444
+ interface AzureCosmosDBNoSQLInitOptions {
445
+ readonly vectorEmbeddingPolicy?: VectorEmbeddingPolicy | undefined;
446
+ readonly indexingPolicy?: IndexingPolicy | undefined;
447
+ readonly createContainerOptions?: AzureCosmosDBNoSqlCreateContainerOptions | undefined;
448
+ readonly createDatabaseOptions?: AzureCosmosDBNoSqlCreateDatabaseOptions | undefined;
449
+ }
450
+ /**
451
+ * Configuration options for the `AzureCosmosDBNoSQLVectorStore` constructor.
452
+ */
453
+ interface AzureCosmosDBNoSQLConfig extends AzureCosmosDBNoSQLInitOptions {
454
+ client?: CosmosClient;
455
+ readonly databaseName?: string;
456
+ readonly containerName?: string;
457
+ readonly textKey?: string;
458
+ readonly metadataKey?: string;
459
+ readonly flatMetadata?: boolean;
460
+ readonly idKey?: string;
461
+ }
462
+ /**
463
+ * Query options for the `AzureCosmosDBNoSQLVectorStore.query` method.
464
+ * @property includeEmbeddings - Whether to include the embeddings in the result. Default false
465
+ * @property includeVectorDistance - Whether to include the vector distance in the result. Default true
466
+ * @property whereClause - The where clause to use in the query. While writing this clause, use `c` as the alias for the container and do not include the `WHERE` keyword.
467
+ */
468
+ interface AzureCosmosQueryOptions {
469
+ includeVectorDistance?: boolean;
470
+ whereClause?: string;
471
+ }
472
+ declare class AzureCosmosDBNoSqlVectorStore extends BaseVectorStore {
473
+ storesText: boolean;
474
+ private initPromise?;
475
+ private container;
476
+ /**
477
+ * The CosmosDB client. This is either passed in or created.
478
+ */
479
+ cosmosClient: CosmosClient;
480
+ /**
481
+ * The key to use for the text field in the CosmosDB container.
482
+ * Default: "text"
483
+ */
484
+ textKey: string;
485
+ flatMetadata: boolean;
486
+ /**
487
+ * The key to use for the id field in the CosmosDB container.
488
+ * Default: "id"
489
+ */
490
+ idKey: string;
491
+ /**
492
+ * The key to use for the metadata field in the CosmosDB container.
493
+ * Default: "metadata"
494
+ */
495
+ metadataKey: string;
496
+ /**
497
+ * The key to use for the vector embedding field in the CosmosDB container.
498
+ * Default: "embedding"
499
+ */
500
+ embeddingKey: string;
501
+ private initialize;
502
+ client(): unknown;
503
+ constructor(dbConfig: AzureCosmosDBNoSQLConfig & VectorStoreBaseParams);
504
+ /**
505
+ * Static method for creating an instance using a connection string.
506
+ * If no connection string is provided, it will attempt to use the env variable `AZURE_COSMOSDB_NOSQL_CONNECTION_STRING` as connection string.
507
+ * @returns Instance of AzureCosmosDBNoSqlVectorStore
508
+ */
509
+ static fromConnectionString(config?: {
510
+ connectionString?: string;
511
+ } & AzureCosmosDBNoSQLConfig & VectorStoreBaseParams): AzureCosmosDBNoSqlVectorStore;
512
+ /**
513
+ * Static method for creating an instance using a account endpoint and key.
514
+ * If no endpoint and key is provided, it will attempt to use the env variable `AZURE_COSMOSDB_NOSQL_ACCOUNT_ENDPOINT` as enpoint and `AZURE_COSMOSDB_NOSQL_ACCOUNT_KEY` as key.
515
+ * @returns Instance of AzureCosmosDBNoSqlVectorStore
516
+ */
517
+ static fromAccountAndKey(config?: {
518
+ endpoint?: string;
519
+ key?: string;
520
+ } & AzureCosmosDBNoSQLConfig & VectorStoreBaseParams): AzureCosmosDBNoSqlVectorStore;
521
+ /**
522
+ * Static method for creating an instance using account endpoint and managed identity.
523
+ * If no endpoint and credentials are provided, it will attempt to use the env variable `AZURE_COSMOSDB_NOSQL_ACCOUNT_ENDPOINT` as endpoint and use DefaultAzureCredential() as credentials.
524
+ * @returns Instance of AzureCosmosDBNoSqlVectorStore
525
+ */
526
+ static fromUriAndManagedIdentity(config?: {
527
+ endpoint?: string;
528
+ credential?: TokenCredential;
529
+ } & AzureCosmosDBNoSQLConfig & VectorStoreBaseParams): AzureCosmosDBNoSqlVectorStore;
530
+ /**
531
+ * Adds document to the CosmosDB container.
532
+ *
533
+ * @returns an array of document ids which were added
534
+ */
535
+ add(nodes: BaseNode[]): Promise<string[]>;
536
+ /**
537
+ * Delete a document from the CosmosDB container.
538
+ *
539
+ * @param refDocId - The id of the document to delete
540
+ * @param deleteOptions - Any options to pass to the container.item.delete function
541
+ * @returns Promise that resolves if the delete query did not throw an error.
542
+ */
543
+ delete(refDocId: string, deleteOptions?: object): Promise<void>;
544
+ /**
545
+ * Performs a vector similarity search query in the CosmosDB container.
546
+ *
547
+ * @param query VectorStoreQuery
548
+ * @returns List of nodes along with similarityScore
549
+ */
550
+ query(query: VectorStoreQuery, options?: AzureCosmosQueryOptions): Promise<VectorStoreQueryResult>;
551
+ /**
552
+ * Initialize the CosmosDB container.
553
+ */
554
+ private init;
555
+ }
556
+
557
+ declare class AzureQueryResultSearchBase<T extends R> {
558
+ protected _query: VectorStoreQuery;
559
+ fieldMapping: Record<string, string>;
560
+ odataFilter: string | undefined;
561
+ searchClient: SearchClient<T> | undefined;
562
+ constructor(query: VectorStoreQuery, fieldMapping: Record<string, string>, odataFilter: string | undefined, searchClient: SearchClient<T> | undefined);
563
+ get selectFields(): string[];
564
+ createSearchQuery(): string;
565
+ protected createQueryVector(): VectorizedQuery<T>[] | null;
566
+ protected _createQueryResult(searchQuery: string, vectorQueries: VectorizedQuery<T>[] | null): Promise<VectorStoreQueryResult>;
567
+ search(): Promise<VectorStoreQueryResult>;
568
+ }
569
+ declare class AzureQueryResultSearchDefault<T extends R> extends AzureQueryResultSearchBase<T> {
570
+ createQueryVector(): VectorizedQuery<T>[];
571
+ }
572
+ declare class AzureQueryResultSearchSparse<T extends R> extends AzureQueryResultSearchBase<T> {
573
+ createSearchQuery(): string;
574
+ }
575
+ declare class AzureQueryResultSearchHybrid<T extends R> extends AzureQueryResultSearchBase<T> {
576
+ createQueryVector(): VectorizedQuery<T>[];
577
+ createSearchQuery(): string;
578
+ }
579
+ declare class AzureQueryResultSearchSemanticHybrid<T extends R> extends AzureQueryResultSearchHybrid<T> {
580
+ createQueryVector(): VectorizedQuery<T>[];
581
+ _createQueryResult(searchQuery: string, vectorQueries: VectorizedQuery<T>[]): Promise<VectorStoreQueryResult>;
582
+ }
583
+
584
+ export { AzureAISearchVectorStore, AzureAISearchVectorStoreConfig, AzureCosmosDBMongoDBSimilarityType, AzureCosmosDBMongoDBVectorStore, AzureCosmosDBNoSqlVectorStore, AzureQueryResultSearchBase, AzureQueryResultSearchDefault, AzureQueryResultSearchHybrid, AzureQueryResultSearchSemanticHybrid, AzureQueryResultSearchSparse, IndexManagement, MetadataIndexFieldType, SimpleCosmosDBReader };
585
+ export type { AzureAISearchOptions, AzureCosmosDBMongoDBIndexOptions, AzureCosmosDBMongoDBQueryOptions, AzureCosmosDBNoSQLConfig, AzureCosmosDBNoSQLInitOptions, AzureCosmosDBNoSqlCreateContainerOptions, AzureCosmosDBNoSqlCreateDatabaseOptions, AzureCosmosQueryOptions, FilterableMetadataFieldKeysType, R, SimpleCosmosDBReaderLoaderConfig };