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 13
13
text_search_stage ,
14
14
vector_search_stage ,
15
15
)
16
+ from .util import append_client_metadata
16
17
17
18
__all__ = [
18
19
"__version__" ,
26
27
"reciprocal_rank_stage" ,
27
28
"final_hybrid_stage" ,
28
29
"bulk_embed_and_insert_texts" ,
30
+ "append_client_metadata" ,
29
31
]
Original file line number Diff line number Diff line change 1
1
import logging
2
2
from typing import Any
3
3
4
+ from pymongo import AsyncMongoClient , MongoClient
5
+ from pymongo .driver_info import DriverInfo
6
+
4
7
logger = logging .getLogger (__file__ )
5
8
6
9
@@ -42,3 +45,9 @@ def oid_to_str(oid: Any) -> str:
42
45
24 character hex string.
43
46
"""
44
47
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