mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
INTPYTHON-724 - Add DriverInfo metadata to MongoDB connector (#13379)
### Motivation and Context This PR updates the MongoDB connector to use best practices for DriverInfo while connecting to the database. ### Description ### Contribution Checklist Passing MongoDB connector tests: https://spruce.mongodb.com/task/ai_ml_pipeline_testing_test_semantic_kernel_python_rhel_test_semantic_kernel_python_local_patch_888cccaf0dc36ca794fde4fd82cb1f997e5a4211_69209c01107dec0007300089_25_11_21_17_06_20/logs?execution=0 <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
This commit is contained in:
@@ -64,6 +64,7 @@ DISTANCE_FUNCTION_MAP: Final[dict[DistanceFunction, str]] = {
|
||||
DistanceFunction.DOT_PROD: "dotProduct",
|
||||
DistanceFunction.DEFAULT: "euclidean",
|
||||
}
|
||||
DRIVER_METADATA = DriverInfo(SEMANTIC_KERNEL_USER_AGENT, metadata.version("semantic-kernel"))
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -210,6 +211,8 @@ class MongoDBAtlasCollection(
|
||||
managed_client=managed_client,
|
||||
embedding_generator=embedding_generator,
|
||||
)
|
||||
if callable(mongo_client.append_metadata):
|
||||
mongo_client.append_metadata(DRIVER_METADATA)
|
||||
return
|
||||
|
||||
try:
|
||||
@@ -225,7 +228,7 @@ class MongoDBAtlasCollection(
|
||||
|
||||
mongo_client = AsyncMongoClient(
|
||||
mongodb_atlas_settings.connection_string.get_secret_value(),
|
||||
driver=DriverInfo(SEMANTIC_KERNEL_USER_AGENT, metadata.version("semantic-kernel")),
|
||||
driver=DRIVER_METADATA,
|
||||
)
|
||||
|
||||
super().__init__(
|
||||
@@ -565,6 +568,8 @@ class MongoDBAtlasStore(VectorStore):
|
||||
database_name=database_name or DEFAULT_DB_NAME,
|
||||
embedding_generator=embedding_generator,
|
||||
)
|
||||
if callable(mongo_client.append_metadata):
|
||||
mongo_client.append_metadata(DRIVER_METADATA)
|
||||
return
|
||||
|
||||
try:
|
||||
@@ -581,7 +586,7 @@ class MongoDBAtlasStore(VectorStore):
|
||||
|
||||
mongo_client = AsyncMongoClient(
|
||||
mongodb_atlas_settings.connection_string.get_secret_value(),
|
||||
driver=DriverInfo(SEMANTIC_KERNEL_USER_AGENT, metadata.version("semantic-kernel")),
|
||||
driver=DRIVER_METADATA,
|
||||
)
|
||||
|
||||
super().__init__(
|
||||
|
||||
Reference in New Issue
Block a user