nvidia-nat-langchain 1.4.0a20251129__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/llm.py +55 -0
- nat/plugins/langchain/tools/tavily_internet_search.py +2 -1
- {nvidia_nat_langchain-1.4.0a20251129.dist-info → nvidia_nat_langchain-1.4.0a20251220.dist-info}/METADATA +2 -2
- {nvidia_nat_langchain-1.4.0a20251129.dist-info → nvidia_nat_langchain-1.4.0a20251220.dist-info}/RECORD +9 -9
- {nvidia_nat_langchain-1.4.0a20251129.dist-info → nvidia_nat_langchain-1.4.0a20251220.dist-info}/WHEEL +0 -0
- {nvidia_nat_langchain-1.4.0a20251129.dist-info → nvidia_nat_langchain-1.4.0a20251220.dist-info}/entry_points.txt +0 -0
- {nvidia_nat_langchain-1.4.0a20251129.dist-info → nvidia_nat_langchain-1.4.0a20251220.dist-info}/licenses/LICENSE-3rd-party.txt +0 -0
- {nvidia_nat_langchain-1.4.0a20251129.dist-info → nvidia_nat_langchain-1.4.0a20251220.dist-info}/licenses/LICENSE.md +0 -0
- {nvidia_nat_langchain-1.4.0a20251129.dist-info → nvidia_nat_langchain-1.4.0a20251220.dist-info}/top_level.txt +0 -0
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
|
|
@@ -195,6 +197,59 @@ async def openai_langchain(llm_config: OpenAIModelConfig, _builder: Builder):
|
|
|
195
197
|
yield _patch_llm_based_on_config(client, llm_config)
|
|
196
198
|
|
|
197
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
|
+
|
|
198
253
|
@register_llm_client(config_type=LiteLlmModelConfig, wrapper_type=LLMFrameworkEnum.LANGCHAIN)
|
|
199
254
|
async def litellm_langchain(llm_config: LiteLlmModelConfig, _builder: Builder):
|
|
200
255
|
|
|
@@ -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
3
|
nat/plugins/langchain/embedder.py,sha256=Ie-J4N4lvygW0zNKklKZVSYxYFcRW6p_QlRdcz0WxcE,3607
|
|
4
|
-
nat/plugins/langchain/llm.py,sha256=
|
|
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
|