mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-18 16:16:33 +00:00
Add Wrapping Library Metadata to MongoDB vector store (#13084)
**Description** MongoDB drivers are used in various flavors and languages. Making sure we exercise our due diligence in identifying the "origin" of the library calls makes it best to understand how our Atlas servers get accessed.
This commit is contained in:
@@ -102,13 +102,18 @@ class MongoDBAtlasVectorSearch(VectorStore):
|
||||
|
||||
"""
|
||||
try:
|
||||
from pymongo import MongoClient
|
||||
from importlib.metadata import version
|
||||
|
||||
from pymongo import DriverInfo, MongoClient
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"Could not import pymongo, please install it with "
|
||||
"`pip install pymongo`."
|
||||
)
|
||||
client: MongoClient = MongoClient(connection_string)
|
||||
client: MongoClient = MongoClient(
|
||||
connection_string,
|
||||
driver=DriverInfo(name="Langchain", version=version("langchain")),
|
||||
)
|
||||
db_name, collection_name = namespace.split(".")
|
||||
collection = client[db_name][collection_name]
|
||||
return cls(collection, embedding, **kwargs)
|
||||
|
Reference in New Issue
Block a user