Skip to content

Commit 91627dc

Browse files
feat: Add MongoDB driver metadata (#2240)
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
1 parent 09ba5aa commit 91627dc

File tree

14 files changed

+112
-57
lines changed

14 files changed

+112
-57
lines changed

.changeset/warm-pants-teach.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@llamaindex/mongodb": minor
3+
"@llamaindex/azure": minor
4+
"@llamaindex/tools": minor
5+
"@llamaindex/examples": minor
6+
---
7+
8+
Update storage providers to append MongoDB client metadata

examples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"dotenv": "^17.2.0",
6868
"js-tiktoken": "^1.0.14",
6969
"llamaindex": "^0.12.0",
70-
"mongodb": "6.7.0",
70+
"mongodb": "6.21.0",
7171
"postgres": "^3.4.4",
7272
"wikipedia": "^2.1.2",
7373
"zod": "^4.1.5"

packages/providers/storage/azure/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"@azure/identity": "^4.4.1",
7373
"@azure/search-documents": "^12.1.0",
7474
"@llamaindex/openai": "workspace:*",
75-
"mongodb": "^6.7.0",
75+
"mongodb": "^6.21.0",
7676
"openai": "^4.90.0"
7777
}
7878
}

packages/providers/storage/azure/src/chatStore/AzureCosmosMongovCoreChatStore.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import type {
77
import { BaseChatStore } from "@llamaindex/core/storage/chat-store";
88
import type { Collection } from "mongodb";
99
import { MongoClient } from "mongodb";
10+
import pkg from "../../package.json";
11+
1012
const DEFAULT_CHAT_DATABASE = "ChatStoreDB";
1113
const DEFAULT_CHAT_Collection = "ChatStoreCollection";
1214

@@ -40,6 +42,10 @@ export class AzureCosmosVCoreChatStore<
4042
"MongoClient is required for AzureCosmosVCoreChatStore initialization",
4143
);
4244
}
45+
mongoClient.appendMetadata({
46+
name: "LLAMAINDEX_AZURE_COSMOS_VCORE_CHAT_STORE",
47+
version: pkg.version,
48+
});
4349
this.mongoClient = mongoClient;
4450
this.dbName = dbName;
4551
this.collectionName = collectionName;

packages/providers/storage/azure/src/kvStore/AzureCosmosMongovCoreKVStore.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { BaseKVStore } from "@llamaindex/core/storage/kv-store";
33
import type { Collection } from "mongodb";
44
import { MongoClient } from "mongodb";
5+
import pkg from "../../package.json";
56
const DEFAULT_CHAT_DATABASE = "KVStoreDB";
67
const DEFAULT_CHAT_Collection = "KVStoreCollection";
78

@@ -38,6 +39,10 @@ export class AzureCosmosVCoreKVStore extends BaseKVStore {
3839
"MongoClient is required for AzureCosmosDBNoSQLVectorStore initialization",
3940
);
4041
}
42+
mongoClient.appendMetadata({
43+
name: "LLAMAINDEX_AZURE_COSMOS_VCORE_KV_STORE",
44+
version: pkg.version,
45+
});
4146
this.mongoClient = mongoClient;
4247
this.dbName = dbName;
4348
this.collectionName = collectionName;

packages/providers/storage/azure/src/vectorStore/AzureCosmosDBMongoVectorStore.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
} from "@llamaindex/core/vector-store";
1111
import { getEnv } from "@llamaindex/env";
1212
import { Collection, Db, MongoClient } from "mongodb";
13+
import pkg from "../../package.json";
1314

1415
/** Azure Cosmos DB for MongoDB vCore Similarity type. */
1516
export const AzureCosmosDBMongoDBSimilarityType = {
@@ -124,6 +125,10 @@ export class AzureCosmosDBMongoDBVectorStore extends BaseVectorStore {
124125
appName: "LLAMAINDEX_JS",
125126
});
126127
}
128+
this.mongodbClient.appendMetadata({
129+
name: "LLAMAINDEX_AZURE_COSMOS_VCORE_VECTOR_STORE",
130+
version: pkg.version,
131+
});
127132

128133
this.dbName = init.dbName ?? "documentsDB";
129134
this.collectionName = init.collectionName ?? "documents";

packages/providers/storage/mongodb/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@
4949
"@llamaindex/env": "workspace:*"
5050
},
5151
"dependencies": {
52-
"mongodb": "6.7.0"
52+
"mongodb": "6.21.0"
5353
}
5454
}

packages/providers/storage/mongodb/src/MongoDBAtlasVectorStore.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
import { getEnv } from "@llamaindex/env";
1717
import type { BulkWriteOptions, Collection } from "mongodb";
1818
import { MongoClient } from "mongodb";
19+
import pkg from "../package.json";
1920

2021
// define your Atlas Search index. See detail https://www.mongodb.com/docs/atlas/atlas-search/field-types/knn-vector/
2122
const DEFAULT_EMBEDDING_DEFINITION = {
@@ -162,6 +163,10 @@ export class MongoDBAtlasVectorSearch extends BaseVectorStore {
162163

163164
this.dbName = init.dbName ?? "default_db";
164165
this.collectionName = init.collectionName ?? "default_collection";
166+
this.mongodbClient.appendMetadata({
167+
name: "LLAMAINDEX_MONGODB_ATLAS_VECTOR_STORE",
168+
version: pkg.version,
169+
});
165170
this.autoCreateIndex = init.autoCreateIndex ?? true;
166171
this.indexedMetadataFields = init.indexedMetadataFields ?? [];
167172
this.embeddingDefinition = {

packages/providers/storage/mongodb/src/docStore/MongoDBDocumentStore.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { KVDocumentStore } from "@llamaindex/core/storage/doc-store";
22
import { MongoClient } from "mongodb";
3+
import pkg from "../../package.json";
34
import { MongoKVStore } from "../kvStore/MongoKVStore";
45

56
const DEFAULT_DATABASE = "DocumentStoreDB";
@@ -36,6 +37,10 @@ export class MongoDocumentStore extends KVDocumentStore {
3637
mongoClient,
3738
dbName,
3839
});
40+
mongoClient.appendMetadata({
41+
name: "LLAMAINDEX_MONGODB_DOC_STORE",
42+
version: pkg.version,
43+
});
3944

4045
return new MongoDocumentStore({
4146
mongoKVStore,

packages/providers/storage/mongodb/src/kvStore/MongoKVStore.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ export class MongoKVStore extends BaseKVStore {
2424

2525
this.mongoClient = mongoClient;
2626
this.dbName = dbName;
27+
this.mongoClient.appendMetadata({
28+
name: "LLAMAINDEX_MONGODB_KV_STORE",
29+
});
2730
}
2831

2932
get client(): MongoClient {

0 commit comments

Comments
 (0)