File tree 8 files changed +31
-37
lines changed
langchain_google_vertexai
8 files changed +31
-37
lines changed Original file line number Diff line number Diff line change @@ -35,14 +35,12 @@ def get_user_agent(module: Optional[str] = None) -> Tuple[str, str]:
35
35
langchain_version = metadata .version ("langchain-google-community" )
36
36
except metadata .PackageNotFoundError :
37
37
langchain_version = "0.0.0"
38
- client_library_version = (
39
- f"{ langchain_version } -{ module } " if module else langchain_version
40
- )
38
+ gapic_version = f"{ langchain_version } -{ module } " if module else langchain_version
41
39
if os .environ .get (_TELEMETRY_ENV_VARIABLE_NAME ):
42
- client_library_version += f"+{ _TELEMETRY_TAG } "
40
+ gapic_version += f"+{ _TELEMETRY_TAG } "
43
41
return (
44
- client_library_version ,
45
- f"langchain-google-community/{ client_library_version } " ,
42
+ gapic_version ,
43
+ f"langchain-google-community/{ gapic_version } " ,
46
44
)
47
45
48
46
@@ -55,9 +53,9 @@ def get_client_info(module: Optional[str] = None) -> "ClientInfo":
55
53
Returns:
56
54
google.api_core.gapic_v1.client_info.ClientInfo
57
55
"""
58
- client_library_version , user_agent = get_user_agent (module )
56
+ gapic_version , user_agent = get_user_agent (module )
59
57
return ClientInfo (
60
- client_library_version = client_library_version ,
58
+ gapic_version = gapic_version ,
61
59
user_agent = user_agent ,
62
60
)
63
61
Original file line number Diff line number Diff line change @@ -12,8 +12,8 @@ def test_get_user_agent_with_telemetry_env_variable(
12
12
) -> None :
13
13
mock_version .return_value = "1.2.3"
14
14
mock_environ_get .return_value = True
15
- client_lib_version , user_agent_str = get_user_agent (module = "test-module" )
16
- assert client_lib_version == "1.2.3-test-module+remote_reasoning_engine"
15
+ gapic_version , user_agent_str = get_user_agent (module = "test-module" )
16
+ assert gapic_version == "1.2.3-test-module+remote_reasoning_engine"
17
17
assert user_agent_str == (
18
18
"langchain-google-community/1.2.3-test-module+remote_reasoning_engine"
19
19
)
@@ -26,6 +26,6 @@ def test_get_user_agent_without_telemetry_env_variable(
26
26
) -> None :
27
27
mock_version .return_value = "1.2.3"
28
28
mock_environ_get .return_value = False
29
- client_lib_version , user_agent_str = get_user_agent (module = "test-module" )
30
- assert client_lib_version == "1.2.3-test-module"
29
+ gapic_version , user_agent_str = get_user_agent (module = "test-module" )
30
+ assert gapic_version == "1.2.3-test-module"
31
31
assert user_agent_str == "langchain-google-community/1.2.3-test-module"
Original file line number Diff line number Diff line change @@ -129,12 +129,10 @@ def get_user_agent(module: Optional[str] = None) -> Tuple[str, str]:
129
129
langchain_version = metadata .version ("langchain-google-genai" )
130
130
except metadata .PackageNotFoundError :
131
131
langchain_version = "0.0.0"
132
- client_library_version = (
133
- f"{ langchain_version } -{ module } " if module else langchain_version
134
- )
132
+ gapic_version = f"{ langchain_version } -{ module } " if module else langchain_version
135
133
if os .environ .get (_TELEMETRY_ENV_VARIABLE_NAME ):
136
- client_library_version += f"+{ _TELEMETRY_TAG } "
137
- return client_library_version , f"langchain-google-genai/{ client_library_version } "
134
+ gapic_version += f"+{ _TELEMETRY_TAG } "
135
+ return gapic_version , f"langchain-google-genai/{ gapic_version } "
138
136
139
137
140
138
def get_client_info (module : Optional [str ] = None ) -> "ClientInfo" :
@@ -146,9 +144,9 @@ def get_client_info(module: Optional[str] = None) -> "ClientInfo":
146
144
Returns:
147
145
google.api_core.gapic_v1.client_info.ClientInfo
148
146
"""
149
- client_library_version , user_agent = get_user_agent (module )
147
+ gapic_version , user_agent = get_user_agent (module )
150
148
return ClientInfo (
151
- client_library_version = client_library_version ,
149
+ gapic_version = gapic_version ,
152
150
user_agent = user_agent ,
153
151
)
154
152
Original file line number Diff line number Diff line change @@ -12,8 +12,8 @@ def test_get_user_agent_with_telemetry_env_variable(
12
12
) -> None :
13
13
mock_version .return_value = "1.2.3"
14
14
mock_environ_get .return_value = True
15
- client_lib_version , user_agent_str = get_user_agent (module = "test-module" )
16
- assert client_lib_version == "1.2.3-test-module+remote_reasoning_engine"
15
+ gapic_version , user_agent_str = get_user_agent (module = "test-module" )
16
+ assert gapic_version == "1.2.3-test-module+remote_reasoning_engine"
17
17
assert user_agent_str == (
18
18
"langchain-google-genai/1.2.3-test-module+remote_reasoning_engine"
19
19
)
@@ -26,6 +26,6 @@ def test_get_user_agent_without_telemetry_env_variable(
26
26
) -> None :
27
27
mock_version .return_value = "1.2.3"
28
28
mock_environ_get .return_value = False
29
- client_lib_version , user_agent_str = get_user_agent (module = "test-module" )
30
- assert client_lib_version == "1.2.3-test-module"
29
+ gapic_version , user_agent_str = get_user_agent (module = "test-module" )
30
+ assert gapic_version == "1.2.3-test-module"
31
31
assert user_agent_str == "langchain-google-genai/1.2.3-test-module"
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ def test_integration_initialization() -> None:
28
28
client_info = mock_prediction_service .call_args .kwargs ["client_info" ]
29
29
assert "langchain-google-genai" in client_info .user_agent
30
30
assert "GoogleGenerativeAIEmbeddings" in client_info .user_agent
31
- assert "GoogleGenerativeAIEmbeddings" in client_info .client_library_version
31
+ assert "GoogleGenerativeAIEmbeddings" in client_info .gapic_version
32
32
33
33
with patch (
34
34
"langchain_google_genai._genai_extension.v1betaGenerativeServiceClient"
Original file line number Diff line number Diff line change @@ -96,12 +96,10 @@ def get_user_agent(module: Optional[str] = None) -> Tuple[str, str]:
96
96
langchain_version = metadata .version ("langchain-google-vertexai" )
97
97
except metadata .PackageNotFoundError :
98
98
langchain_version = "0.0.0"
99
- client_library_version = (
100
- f"{ langchain_version } -{ module } " if module else langchain_version
101
- )
99
+ gapic_version = f"{ langchain_version } -{ module } " if module else langchain_version
102
100
if os .environ .get (_TELEMETRY_ENV_VARIABLE_NAME ):
103
- client_library_version += f"+{ _TELEMETRY_TAG } "
104
- return client_library_version , f"langchain-google-vertexai/{ client_library_version } "
101
+ gapic_version += f"+{ _TELEMETRY_TAG } "
102
+ return gapic_version , f"langchain-google-vertexai/{ gapic_version } "
105
103
106
104
107
105
def get_client_info (module : Optional [str ] = None ) -> "ClientInfo" :
@@ -113,9 +111,9 @@ def get_client_info(module: Optional[str] = None) -> "ClientInfo":
113
111
Returns:
114
112
google.api_core.gapic_v1.client_info.ClientInfo
115
113
"""
116
- client_library_version , user_agent = get_user_agent (module )
114
+ gapic_version , user_agent = get_user_agent (module )
117
115
return ClientInfo (
118
- client_library_version = client_library_version ,
116
+ gapic_version = gapic_version ,
119
117
user_agent = user_agent ,
120
118
)
121
119
Original file line number Diff line number Diff line change @@ -125,8 +125,8 @@ def test_init_client(model: str, location: str) -> None:
125
125
assert client_options .api_endpoint == f"{ location } -aiplatform.googleapis.com"
126
126
assert "langchain-google-vertexai" in client_info .user_agent
127
127
assert "ChatVertexAI" in client_info .user_agent
128
- assert "langchain-google-vertexai" in client_info .client_library_version
129
- assert "ChatVertexAI" in client_info .client_library_version
128
+ assert "langchain-google-vertexai" in client_info .gapic_version
129
+ assert "ChatVertexAI" in client_info .gapic_version
130
130
assert llm .full_model_name == (
131
131
f"projects/test-proj/locations/{ location } /publishers/google/models/gemini-1.0-pro-001"
132
132
)
Original file line number Diff line number Diff line change @@ -193,8 +193,8 @@ def test_get_user_agent_with_telemetry_env_variable(
193
193
) -> None :
194
194
mock_version .return_value = "1.2.3"
195
195
mock_environ_get .return_value = True
196
- client_lib_version , user_agent_str = get_user_agent (module = "test-module" )
197
- assert client_lib_version == "1.2.3-test-module+remote_reasoning_engine"
196
+ gapic_version , user_agent_str = get_user_agent (module = "test-module" )
197
+ assert gapic_version == "1.2.3-test-module+remote_reasoning_engine"
198
198
assert user_agent_str == (
199
199
"langchain-google-vertexai/1.2.3-test-module+remote_reasoning_engine"
200
200
)
@@ -207,6 +207,6 @@ def test_get_user_agent_without_telemetry_env_variable(
207
207
) -> None :
208
208
mock_version .return_value = "1.2.3"
209
209
mock_environ_get .return_value = False
210
- client_lib_version , user_agent_str = get_user_agent (module = "test-module" )
211
- assert client_lib_version == "1.2.3-test-module"
210
+ gapic_version , user_agent_str = get_user_agent (module = "test-module" )
211
+ assert gapic_version == "1.2.3-test-module"
212
212
assert user_agent_str == "langchain-google-vertexai/1.2.3-test-module"
You can’t perform that action at this time.
0 commit comments