mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +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:
parent
21552628c8
commit
c1b041c188
@ -102,13 +102,18 @@ class MongoDBAtlasVectorSearch(VectorStore):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
from pymongo import MongoClient
|
from importlib.metadata import version
|
||||||
|
|
||||||
|
from pymongo import DriverInfo, MongoClient
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ImportError(
|
raise ImportError(
|
||||||
"Could not import pymongo, please install it with "
|
"Could not import pymongo, please install it with "
|
||||||
"`pip install pymongo`."
|
"`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(".")
|
db_name, collection_name = namespace.split(".")
|
||||||
collection = client[db_name][collection_name]
|
collection = client[db_name][collection_name]
|
||||||
return cls(collection, embedding, **kwargs)
|
return cls(collection, embedding, **kwargs)
|
||||||
|
Loading…
Reference in New Issue
Block a user