nvidia-nat-langchain 1.4.0a20251031__py3-none-any.whl → 1.4.0a20251220__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of nvidia-nat-langchain might be problematic. Click here for more details.
- nat/plugins/langchain/embedder.py +11 -3
- nat/plugins/langchain/llm.py +72 -6
- nat/plugins/langchain/tools/tavily_internet_search.py +2 -1
- {nvidia_nat_langchain-1.4.0a20251031.dist-info → nvidia_nat_langchain-1.4.0a20251220.dist-info}/METADATA +2 -2
- {nvidia_nat_langchain-1.4.0a20251031.dist-info → nvidia_nat_langchain-1.4.0a20251220.dist-info}/RECORD +10 -10
- {nvidia_nat_langchain-1.4.0a20251031.dist-info → nvidia_nat_langchain-1.4.0a20251220.dist-info}/WHEEL +0 -0
- {nvidia_nat_langchain-1.4.0a20251031.dist-info → nvidia_nat_langchain-1.4.0a20251220.dist-info}/entry_points.txt +0 -0
- {nvidia_nat_langchain-1.4.0a20251031.dist-info → nvidia_nat_langchain-1.4.0a20251220.dist-info}/licenses/LICENSE-3rd-party.txt +0 -0
- {nvidia_nat_langchain-1.4.0a20251031.dist-info → nvidia_nat_langchain-1.4.0a20251220.dist-info}/licenses/LICENSE.md +0 -0
- {nvidia_nat_langchain-1.4.0a20251031.dist-info → nvidia_nat_langchain-1.4.0a20251220.dist-info}/top_level.txt +0 -0
|
@@ -28,7 +28,13 @@ async def azure_openai_langchain(embedder_config: AzureOpenAIEmbedderModelConfig
|
|
|
28
28
|
|
|
29
29
|
from langchain_openai import AzureOpenAIEmbeddings
|
|
30
30
|
|
|
31
|
-
client = AzureOpenAIEmbeddings(
|
|
31
|
+
client = AzureOpenAIEmbeddings(
|
|
32
|
+
**embedder_config.model_dump(exclude={"type", "api_version"},
|
|
33
|
+
by_alias=True,
|
|
34
|
+
exclude_none=True,
|
|
35
|
+
exclude_unset=True),
|
|
36
|
+
api_version=embedder_config.api_version,
|
|
37
|
+
)
|
|
32
38
|
|
|
33
39
|
if isinstance(embedder_config, RetryMixin):
|
|
34
40
|
client = patch_with_retry(client,
|
|
@@ -44,7 +50,8 @@ async def nim_langchain(embedder_config: NIMEmbedderModelConfig, builder: Builde
|
|
|
44
50
|
|
|
45
51
|
from langchain_nvidia_ai_endpoints import NVIDIAEmbeddings
|
|
46
52
|
|
|
47
|
-
client = NVIDIAEmbeddings(
|
|
53
|
+
client = NVIDIAEmbeddings(
|
|
54
|
+
**embedder_config.model_dump(exclude={"type"}, by_alias=True, exclude_none=True, exclude_unset=True))
|
|
48
55
|
|
|
49
56
|
if isinstance(embedder_config, RetryMixin):
|
|
50
57
|
client = patch_with_retry(client,
|
|
@@ -60,7 +67,8 @@ async def openai_langchain(embedder_config: OpenAIEmbedderModelConfig, builder:
|
|
|
60
67
|
|
|
61
68
|
from langchain_openai import OpenAIEmbeddings
|
|
62
69
|
|
|
63
|
-
client = OpenAIEmbeddings(
|
|
70
|
+
client = OpenAIEmbeddings(
|
|
71
|
+
**embedder_config.model_dump(exclude={"type"}, by_alias=True, exclude_none=True, exclude_unset=True))
|
|
64
72
|
|
|
65
73
|
if isinstance(embedder_config, RetryMixin):
|
|
66
74
|
client = patch_with_retry(client,
|
nat/plugins/langchain/llm.py
CHANGED
|
@@ -27,6 +27,8 @@ from nat.data_models.retry_mixin import RetryMixin
|
|
|
27
27
|
from nat.data_models.thinking_mixin import ThinkingMixin
|
|
28
28
|
from nat.llm.aws_bedrock_llm import AWSBedrockModelConfig
|
|
29
29
|
from nat.llm.azure_openai_llm import AzureOpenAIModelConfig
|
|
30
|
+
from nat.llm.dynamo_llm import DynamoModelConfig
|
|
31
|
+
from nat.llm.dynamo_llm import create_httpx_client_with_dynamo_hooks
|
|
30
32
|
from nat.llm.litellm_llm import LiteLlmModelConfig
|
|
31
33
|
from nat.llm.nim_llm import NIMModelConfig
|
|
32
34
|
from nat.llm.openai_llm import OpenAIModelConfig
|
|
@@ -122,6 +124,7 @@ async def aws_bedrock_langchain(llm_config: AWSBedrockModelConfig, _builder: Bui
|
|
|
122
124
|
exclude={"type", "context_size", "thinking", "api_type"},
|
|
123
125
|
by_alias=True,
|
|
124
126
|
exclude_none=True,
|
|
127
|
+
exclude_unset=True,
|
|
125
128
|
))
|
|
126
129
|
|
|
127
130
|
yield _patch_llm_based_on_config(client, llm_config)
|
|
@@ -135,7 +138,12 @@ async def azure_openai_langchain(llm_config: AzureOpenAIModelConfig, _builder: B
|
|
|
135
138
|
validate_no_responses_api(llm_config, LLMFrameworkEnum.LANGCHAIN)
|
|
136
139
|
|
|
137
140
|
client = AzureChatOpenAI(
|
|
138
|
-
**llm_config.model_dump(exclude={"type", "thinking", "api_type"
|
|
141
|
+
**llm_config.model_dump(exclude={"type", "thinking", "api_type", "api_version"},
|
|
142
|
+
by_alias=True,
|
|
143
|
+
exclude_none=True,
|
|
144
|
+
exclude_unset=True),
|
|
145
|
+
api_version=llm_config.api_version,
|
|
146
|
+
)
|
|
139
147
|
|
|
140
148
|
yield _patch_llm_based_on_config(client, llm_config)
|
|
141
149
|
|
|
@@ -149,9 +157,12 @@ async def nim_langchain(llm_config: NIMModelConfig, _builder: Builder):
|
|
|
149
157
|
|
|
150
158
|
# prefer max_completion_tokens over max_tokens
|
|
151
159
|
client = ChatNVIDIA(
|
|
152
|
-
**llm_config.model_dump(
|
|
153
|
-
|
|
154
|
-
|
|
160
|
+
**llm_config.model_dump(
|
|
161
|
+
exclude={"type", "max_tokens", "thinking", "api_type"},
|
|
162
|
+
by_alias=True,
|
|
163
|
+
exclude_none=True,
|
|
164
|
+
exclude_unset=True,
|
|
165
|
+
),
|
|
155
166
|
max_completion_tokens=llm_config.max_tokens,
|
|
156
167
|
)
|
|
157
168
|
|
|
@@ -171,6 +182,7 @@ async def openai_langchain(llm_config: OpenAIModelConfig, _builder: Builder):
|
|
|
171
182
|
exclude={"type", "thinking", "api_type"},
|
|
172
183
|
by_alias=True,
|
|
173
184
|
exclude_none=True,
|
|
185
|
+
exclude_unset=True,
|
|
174
186
|
))
|
|
175
187
|
else:
|
|
176
188
|
# If stream_usage is specified, it will override the default value of True.
|
|
@@ -179,11 +191,65 @@ async def openai_langchain(llm_config: OpenAIModelConfig, _builder: Builder):
|
|
|
179
191
|
exclude={"type", "thinking", "api_type"},
|
|
180
192
|
by_alias=True,
|
|
181
193
|
exclude_none=True,
|
|
194
|
+
exclude_unset=True,
|
|
182
195
|
))
|
|
183
196
|
|
|
184
197
|
yield _patch_llm_based_on_config(client, llm_config)
|
|
185
198
|
|
|
186
199
|
|
|
200
|
+
@register_llm_client(config_type=DynamoModelConfig, wrapper_type=LLMFrameworkEnum.LANGCHAIN)
|
|
201
|
+
async def dynamo_langchain(llm_config: DynamoModelConfig, _builder: Builder):
|
|
202
|
+
"""
|
|
203
|
+
Create a LangChain ChatOpenAI client for Dynamo with automatic prefix header injection.
|
|
204
|
+
|
|
205
|
+
This client injects Dynamo prefix headers at the HTTP transport level using httpx event hooks,
|
|
206
|
+
enabling KV cache optimization and request routing.
|
|
207
|
+
"""
|
|
208
|
+
from langchain_openai import ChatOpenAI
|
|
209
|
+
|
|
210
|
+
# Build config dict excluding Dynamo-specific and NAT-specific fields
|
|
211
|
+
config_dict = llm_config.model_dump(
|
|
212
|
+
exclude={"type", "thinking", "api_type", *DynamoModelConfig.get_dynamo_field_names()},
|
|
213
|
+
by_alias=True,
|
|
214
|
+
exclude_none=True,
|
|
215
|
+
exclude_unset=True,
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
# Initialize http_async_client to None for proper cleanup
|
|
219
|
+
http_async_client = None
|
|
220
|
+
|
|
221
|
+
try:
|
|
222
|
+
# If prefix_template is set, create a custom httpx client with Dynamo hooks
|
|
223
|
+
if llm_config.prefix_template is not None:
|
|
224
|
+
http_async_client = create_httpx_client_with_dynamo_hooks(
|
|
225
|
+
prefix_template=llm_config.prefix_template,
|
|
226
|
+
total_requests=llm_config.prefix_total_requests,
|
|
227
|
+
osl=llm_config.prefix_osl,
|
|
228
|
+
iat=llm_config.prefix_iat,
|
|
229
|
+
timeout=llm_config.request_timeout,
|
|
230
|
+
)
|
|
231
|
+
config_dict["http_async_client"] = http_async_client
|
|
232
|
+
logger.info(
|
|
233
|
+
"Dynamo prefix headers enabled: template=%s, total_requests=%d, osl=%s, iat=%s",
|
|
234
|
+
llm_config.prefix_template,
|
|
235
|
+
llm_config.prefix_total_requests,
|
|
236
|
+
llm_config.prefix_osl,
|
|
237
|
+
llm_config.prefix_iat,
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
# Create the ChatOpenAI client
|
|
241
|
+
if llm_config.api_type == APITypeEnum.RESPONSES:
|
|
242
|
+
client = ChatOpenAI(stream_usage=True, use_responses_api=True, use_previous_response_id=True, **config_dict)
|
|
243
|
+
else:
|
|
244
|
+
client = ChatOpenAI(stream_usage=True, **config_dict)
|
|
245
|
+
|
|
246
|
+
yield _patch_llm_based_on_config(client, llm_config)
|
|
247
|
+
finally:
|
|
248
|
+
# Ensure the httpx client is properly closed to avoid resource leaks
|
|
249
|
+
if http_async_client is not None:
|
|
250
|
+
await http_async_client.aclose()
|
|
251
|
+
|
|
252
|
+
|
|
187
253
|
@register_llm_client(config_type=LiteLlmModelConfig, wrapper_type=LLMFrameworkEnum.LANGCHAIN)
|
|
188
254
|
async def litellm_langchain(llm_config: LiteLlmModelConfig, _builder: Builder):
|
|
189
255
|
|
|
@@ -191,7 +257,7 @@ async def litellm_langchain(llm_config: LiteLlmModelConfig, _builder: Builder):
|
|
|
191
257
|
|
|
192
258
|
validate_no_responses_api(llm_config, LLMFrameworkEnum.LANGCHAIN)
|
|
193
259
|
|
|
194
|
-
client = ChatLiteLLM(
|
|
195
|
-
|
|
260
|
+
client = ChatLiteLLM(**llm_config.model_dump(
|
|
261
|
+
exclude={"type", "thinking", "api_type"}, by_alias=True, exclude_none=True, exclude_unset=True))
|
|
196
262
|
|
|
197
263
|
yield _patch_llm_based_on_config(client, llm_config)
|
|
@@ -30,7 +30,8 @@ class TavilyInternetSearchToolConfig(FunctionBaseConfig, name="tavily_internet_s
|
|
|
30
30
|
Requires a TAVILY_API_KEY.
|
|
31
31
|
"""
|
|
32
32
|
max_results: int = 3
|
|
33
|
-
api_key: SerializableSecretStr = Field(
|
|
33
|
+
api_key: SerializableSecretStr = Field(default_factory=lambda: SerializableSecretStr(""),
|
|
34
|
+
description="The API key for the Tavily service.")
|
|
34
35
|
|
|
35
36
|
|
|
36
37
|
@register_function(config_type=TavilyInternetSearchToolConfig)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nvidia-nat-langchain
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.0a20251220
|
|
4
4
|
Summary: Subpackage for LangChain/LangGraph integration in NeMo Agent toolkit
|
|
5
5
|
Author: NVIDIA Corporation
|
|
6
6
|
Maintainer: NVIDIA Corporation
|
|
@@ -16,7 +16,7 @@ Requires-Python: <3.14,>=3.11
|
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE-3rd-party.txt
|
|
18
18
|
License-File: LICENSE.md
|
|
19
|
-
Requires-Dist: nvidia-nat==v1.4.
|
|
19
|
+
Requires-Dist: nvidia-nat==v1.4.0a20251220
|
|
20
20
|
Requires-Dist: langchain~=0.3.27
|
|
21
21
|
Requires-Dist: langchain-aws~=0.2.31
|
|
22
22
|
Requires-Dist: langchain-core~=0.3.75
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
nat/meta/pypi.md,sha256=T_KFtTXVxhFM8Y6K3OlNByA5sTXLQuqqUpHgNOCvZBU,1120
|
|
2
2
|
nat/plugins/langchain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
nat/plugins/langchain/embedder.py,sha256=
|
|
4
|
-
nat/plugins/langchain/llm.py,sha256=
|
|
3
|
+
nat/plugins/langchain/embedder.py,sha256=Ie-J4N4lvygW0zNKklKZVSYxYFcRW6p_QlRdcz0WxcE,3607
|
|
4
|
+
nat/plugins/langchain/llm.py,sha256=JBeYfhD0IGS6W-Jl6vfDqUR8Pdji5zYua2cp3fr_vyw,10950
|
|
5
5
|
nat/plugins/langchain/register.py,sha256=jgq6wSJoGQIZFJhS8RbUs25cLgNJjCkFu4M6qaWJS_4,906
|
|
6
6
|
nat/plugins/langchain/retriever.py,sha256=SWbXXOezEUuPACnmSSU497NAmEVEMj2SrFJGodkRg34,2644
|
|
7
7
|
nat/plugins/langchain/tool_wrapper.py,sha256=Zgb2_XB4bEhjPPeqS-ZH_OJT_pcQmteX7u03N_qCLfc,2121
|
|
8
8
|
nat/plugins/langchain/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
nat/plugins/langchain/tools/code_generation_tool.py,sha256=f5pna0WMOx3QOS4WnaMFKD7tBZ1-tS0PfI0IMYobtTQ,2723
|
|
10
10
|
nat/plugins/langchain/tools/register.py,sha256=uemxqLxcNk1bGX4crV52oMphLTZWonStzkXwTZeG2Rw,889
|
|
11
|
-
nat/plugins/langchain/tools/tavily_internet_search.py,sha256=
|
|
11
|
+
nat/plugins/langchain/tools/tavily_internet_search.py,sha256=tXWYPE9nRVWZVy8lZAAFfOwy_zOm4iU5HxAFltNzE70,3010
|
|
12
12
|
nat/plugins/langchain/tools/wikipedia_search.py,sha256=431YwLsjoC_mdvMZ_gY0Q37Uqaue2ASnAHpwr4jWCaU,2197
|
|
13
|
-
nvidia_nat_langchain-1.4.
|
|
14
|
-
nvidia_nat_langchain-1.4.
|
|
15
|
-
nvidia_nat_langchain-1.4.
|
|
16
|
-
nvidia_nat_langchain-1.4.
|
|
17
|
-
nvidia_nat_langchain-1.4.
|
|
18
|
-
nvidia_nat_langchain-1.4.
|
|
19
|
-
nvidia_nat_langchain-1.4.
|
|
13
|
+
nvidia_nat_langchain-1.4.0a20251220.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
|
|
14
|
+
nvidia_nat_langchain-1.4.0a20251220.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
15
|
+
nvidia_nat_langchain-1.4.0a20251220.dist-info/METADATA,sha256=q81NJfzfriPKA-AWIoRBDNwthsF3XbS_dv-RlQPJyxQ,2263
|
|
16
|
+
nvidia_nat_langchain-1.4.0a20251220.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
17
|
+
nvidia_nat_langchain-1.4.0a20251220.dist-info/entry_points.txt,sha256=4deXsMn97I012HhDw0UjoqcZ8eEoZ7BnqaRx5QmzebY,123
|
|
18
|
+
nvidia_nat_langchain-1.4.0a20251220.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
|
|
19
|
+
nvidia_nat_langchain-1.4.0a20251220.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|