File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
pymongo_vectorsearch_utils Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 1313 text_search_stage ,
1414 vector_search_stage ,
1515)
16+ from .util import append_client_metadata
1617
1718__all__ = [
1819 "__version__" ,
2627 "reciprocal_rank_stage" ,
2728 "final_hybrid_stage" ,
2829 "bulk_embed_and_insert_texts" ,
30+ "append_client_metadata" ,
2931]
Original file line number Diff line number Diff line change 11import logging
22from typing import Any
33
4+ from pymongo import AsyncMongoClient , MongoClient
5+ from pymongo .driver_info import DriverInfo
6+
47logger = logging .getLogger (__file__ )
58
69
@@ -42,3 +45,9 @@ def oid_to_str(oid: Any) -> str:
4245 24 character hex string.
4346 """
4447 return str (oid )
48+
49+
50+ def append_client_metadata (client : MongoClient | AsyncMongoClient , driver_info : DriverInfo ) -> None :
51+ # append_metadata was added in PyMongo 4.14.0, but is a valid database name on earlier versions
52+ if callable (client .append_metadata ):
53+ client .append_metadata (driver_info )
You can’t perform that action at this time.
0 commit comments