File tree Expand file tree Collapse file tree 3 files changed +39
-2
lines changed
langgraph-checkpoint-aws/langgraph_checkpoint_aws Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,39 @@ def setup_logging():
35
35
36
36
setup_logging ()
37
37
38
+
39
+ try :
40
+ import boto3
41
+ from botocore .config import Config
42
+
43
+ FRAMEWORK_UA = "x-client-framework:langchain-aws"
44
+ ORIGINAL_BOTO3_CLIENT = boto3 .client
45
+ ORIGINAL_SESSION_CLIENT = boto3 .session .Session .client
46
+
47
+ def _ensure_framework_ua (cfg : Config | None ) -> Config :
48
+ """Return a Config guaranteed to contain our framework UA tag."""
49
+ if cfg is None :
50
+ return Config (user_agent_extra = FRAMEWORK_UA )
51
+ existing = getattr (cfg , "user_agent_extra" , "" ) or ""
52
+ if FRAMEWORK_UA in existing :
53
+ return cfg
54
+ merged_extra = f"{ existing } { FRAMEWORK_UA } " .strip ()
55
+ return cfg .merge (Config (user_agent_extra = merged_extra ))
56
+
57
+ def _patched_boto3_client (* args , ** kwargs ):
58
+ kwargs ["config" ] = _ensure_framework_ua (kwargs .get ("config" ))
59
+ return ORIGINAL_BOTO3_CLIENT (* args , ** kwargs )
60
+
61
+ def _patched_session_client (self , * args , ** kwargs ):
62
+ kwargs ["config" ] = _ensure_framework_ua (kwargs .get ("config" ))
63
+ return ORIGINAL_SESSION_CLIENT (self , * args , ** kwargs )
64
+
65
+ boto3 .client = _patched_boto3_client
66
+ boto3 .session .Session .client = _patched_session_client
67
+ except Exception :
68
+ pass
69
+
70
+
38
71
__all__ = [
39
72
"BedrockEmbeddings" ,
40
73
"BedrockLLM" ,
Original file line number Diff line number Diff line change @@ -64,7 +64,8 @@ def get_boto_session(
64
64
# Update user agent
65
65
existing_user_agent = getattr (config , "user_agent_extra" , "" ) or ""
66
66
config .user_agent_extra = (
67
- f"{ existing_user_agent } md/sdk_user_agent/{ SDK_USER_AGENT } " .strip ()
67
+ f"{ existing_user_agent } x-client-framework:langchain-aws "
68
+ f"md/sdk_user_agent/{ SDK_USER_AGENT } " .strip ()
68
69
)
69
70
client_params = {"config" : config }
70
71
Original file line number Diff line number Diff line change @@ -441,6 +441,9 @@ def create_client_config(config: Optional[Config] = None) -> Config:
441
441
"""
442
442
config_kwargs = {}
443
443
existing_user_agent = getattr (config , "user_agent_extra" , "" ) if config else ""
444
- new_user_agent = f"{ existing_user_agent } md/sdk_user_agent/{ SDK_USER_AGENT } " .strip ()
444
+ new_user_agent = (
445
+ f"{ existing_user_agent } x-client-framework:langgraph-checkpoint-aws "
446
+ f"md/sdk_user_agent/{ SDK_USER_AGENT } " .strip ()
447
+ )
445
448
446
449
return Config (user_agent_extra = new_user_agent , ** config_kwargs )
You can’t perform that action at this time.
0 commit comments