nvidia-nat-langchain 1.3.0rc5__py3-none-any.whl → 1.4.0a20251216__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.
- nat/plugins/langchain/embedder.py +11 -3
- nat/plugins/langchain/llm.py +50 -11
- nat/plugins/langchain/tools/tavily_internet_search.py +7 -2
- {nvidia_nat_langchain-1.3.0rc5.dist-info → nvidia_nat_langchain-1.4.0a20251216.dist-info}/METADATA +3 -2
- nvidia_nat_langchain-1.4.0a20251216.dist-info/RECORD +19 -0
- nvidia_nat_langchain-1.3.0rc5.dist-info/RECORD +0 -19
- {nvidia_nat_langchain-1.3.0rc5.dist-info → nvidia_nat_langchain-1.4.0a20251216.dist-info}/WHEEL +0 -0
- {nvidia_nat_langchain-1.3.0rc5.dist-info → nvidia_nat_langchain-1.4.0a20251216.dist-info}/entry_points.txt +0 -0
- {nvidia_nat_langchain-1.3.0rc5.dist-info → nvidia_nat_langchain-1.4.0a20251216.dist-info}/licenses/LICENSE-3rd-party.txt +0 -0
- {nvidia_nat_langchain-1.3.0rc5.dist-info → nvidia_nat_langchain-1.4.0a20251216.dist-info}/licenses/LICENSE.md +0 -0
- {nvidia_nat_langchain-1.3.0rc5.dist-info → nvidia_nat_langchain-1.4.0a20251216.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
|
@@ -12,13 +12,16 @@
|
|
|
12
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
|
+
# pylint: disable=unused-argument
|
|
15
16
|
|
|
17
|
+
import logging
|
|
16
18
|
from collections.abc import Sequence
|
|
17
19
|
from typing import TypeVar
|
|
18
20
|
|
|
19
21
|
from nat.builder.builder import Builder
|
|
20
22
|
from nat.builder.framework_enum import LLMFrameworkEnum
|
|
21
23
|
from nat.cli.register_workflow import register_llm_client
|
|
24
|
+
from nat.data_models.llm import APITypeEnum
|
|
22
25
|
from nat.data_models.llm import LLMBaseConfig
|
|
23
26
|
from nat.data_models.retry_mixin import RetryMixin
|
|
24
27
|
from nat.data_models.thinking_mixin import ThinkingMixin
|
|
@@ -31,8 +34,11 @@ from nat.llm.utils.thinking import BaseThinkingInjector
|
|
|
31
34
|
from nat.llm.utils.thinking import FunctionArgumentWrapper
|
|
32
35
|
from nat.llm.utils.thinking import patch_with_thinking
|
|
33
36
|
from nat.utils.exception_handlers.automatic_retries import patch_with_retry
|
|
37
|
+
from nat.utils.responses_api import validate_no_responses_api
|
|
34
38
|
from nat.utils.type_utils import override
|
|
35
39
|
|
|
40
|
+
logger = logging.getLogger(__name__)
|
|
41
|
+
|
|
36
42
|
ModelType = TypeVar("ModelType")
|
|
37
43
|
|
|
38
44
|
|
|
@@ -110,10 +116,13 @@ async def aws_bedrock_langchain(llm_config: AWSBedrockModelConfig, _builder: Bui
|
|
|
110
116
|
|
|
111
117
|
from langchain_aws import ChatBedrockConverse
|
|
112
118
|
|
|
119
|
+
validate_no_responses_api(llm_config, LLMFrameworkEnum.LANGCHAIN)
|
|
120
|
+
|
|
113
121
|
client = ChatBedrockConverse(**llm_config.model_dump(
|
|
114
|
-
exclude={"type", "context_size", "thinking"},
|
|
122
|
+
exclude={"type", "context_size", "thinking", "api_type"},
|
|
115
123
|
by_alias=True,
|
|
116
124
|
exclude_none=True,
|
|
125
|
+
exclude_unset=True,
|
|
117
126
|
))
|
|
118
127
|
|
|
119
128
|
yield _patch_llm_based_on_config(client, llm_config)
|
|
@@ -124,7 +133,15 @@ async def azure_openai_langchain(llm_config: AzureOpenAIModelConfig, _builder: B
|
|
|
124
133
|
|
|
125
134
|
from langchain_openai import AzureChatOpenAI
|
|
126
135
|
|
|
127
|
-
|
|
136
|
+
validate_no_responses_api(llm_config, LLMFrameworkEnum.LANGCHAIN)
|
|
137
|
+
|
|
138
|
+
client = AzureChatOpenAI(
|
|
139
|
+
**llm_config.model_dump(exclude={"type", "thinking", "api_type", "api_version"},
|
|
140
|
+
by_alias=True,
|
|
141
|
+
exclude_none=True,
|
|
142
|
+
exclude_unset=True),
|
|
143
|
+
api_version=llm_config.api_version,
|
|
144
|
+
)
|
|
128
145
|
|
|
129
146
|
yield _patch_llm_based_on_config(client, llm_config)
|
|
130
147
|
|
|
@@ -134,9 +151,16 @@ async def nim_langchain(llm_config: NIMModelConfig, _builder: Builder):
|
|
|
134
151
|
|
|
135
152
|
from langchain_nvidia_ai_endpoints import ChatNVIDIA
|
|
136
153
|
|
|
154
|
+
validate_no_responses_api(llm_config, LLMFrameworkEnum.LANGCHAIN)
|
|
155
|
+
|
|
137
156
|
# prefer max_completion_tokens over max_tokens
|
|
138
157
|
client = ChatNVIDIA(
|
|
139
|
-
**llm_config.model_dump(
|
|
158
|
+
**llm_config.model_dump(
|
|
159
|
+
exclude={"type", "max_tokens", "thinking", "api_type"},
|
|
160
|
+
by_alias=True,
|
|
161
|
+
exclude_none=True,
|
|
162
|
+
exclude_unset=True,
|
|
163
|
+
),
|
|
140
164
|
max_completion_tokens=llm_config.max_tokens,
|
|
141
165
|
)
|
|
142
166
|
|
|
@@ -148,13 +172,25 @@ async def openai_langchain(llm_config: OpenAIModelConfig, _builder: Builder):
|
|
|
148
172
|
|
|
149
173
|
from langchain_openai import ChatOpenAI
|
|
150
174
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
175
|
+
if llm_config.api_type == APITypeEnum.RESPONSES:
|
|
176
|
+
client = ChatOpenAI(stream_usage=True,
|
|
177
|
+
use_responses_api=True,
|
|
178
|
+
use_previous_response_id=True,
|
|
179
|
+
**llm_config.model_dump(
|
|
180
|
+
exclude={"type", "thinking", "api_type"},
|
|
181
|
+
by_alias=True,
|
|
182
|
+
exclude_none=True,
|
|
183
|
+
exclude_unset=True,
|
|
184
|
+
))
|
|
185
|
+
else:
|
|
186
|
+
# If stream_usage is specified, it will override the default value of True.
|
|
187
|
+
client = ChatOpenAI(stream_usage=True,
|
|
188
|
+
**llm_config.model_dump(
|
|
189
|
+
exclude={"type", "thinking", "api_type"},
|
|
190
|
+
by_alias=True,
|
|
191
|
+
exclude_none=True,
|
|
192
|
+
exclude_unset=True,
|
|
193
|
+
))
|
|
158
194
|
|
|
159
195
|
yield _patch_llm_based_on_config(client, llm_config)
|
|
160
196
|
|
|
@@ -164,6 +200,9 @@ async def litellm_langchain(llm_config: LiteLlmModelConfig, _builder: Builder):
|
|
|
164
200
|
|
|
165
201
|
from langchain_litellm import ChatLiteLLM
|
|
166
202
|
|
|
167
|
-
|
|
203
|
+
validate_no_responses_api(llm_config, LLMFrameworkEnum.LANGCHAIN)
|
|
204
|
+
|
|
205
|
+
client = ChatLiteLLM(**llm_config.model_dump(
|
|
206
|
+
exclude={"type", "thinking", "api_type"}, by_alias=True, exclude_none=True, exclude_unset=True))
|
|
168
207
|
|
|
169
208
|
yield _patch_llm_based_on_config(client, llm_config)
|
|
@@ -13,9 +13,13 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
|
+
from pydantic import Field
|
|
17
|
+
|
|
16
18
|
from nat.builder.builder import Builder
|
|
17
19
|
from nat.builder.function_info import FunctionInfo
|
|
18
20
|
from nat.cli.register_workflow import register_function
|
|
21
|
+
from nat.data_models.common import SerializableSecretStr
|
|
22
|
+
from nat.data_models.common import get_secret_value
|
|
19
23
|
from nat.data_models.function import FunctionBaseConfig
|
|
20
24
|
|
|
21
25
|
|
|
@@ -26,7 +30,7 @@ class TavilyInternetSearchToolConfig(FunctionBaseConfig, name="tavily_internet_s
|
|
|
26
30
|
Requires a TAVILY_API_KEY.
|
|
27
31
|
"""
|
|
28
32
|
max_results: int = 3
|
|
29
|
-
api_key:
|
|
33
|
+
api_key: SerializableSecretStr = Field(default="", description="The API key for the Tavily service.")
|
|
30
34
|
|
|
31
35
|
|
|
32
36
|
@register_function(config_type=TavilyInternetSearchToolConfig)
|
|
@@ -36,7 +40,8 @@ async def tavily_internet_search(tool_config: TavilyInternetSearchToolConfig, bu
|
|
|
36
40
|
from langchain_tavily import TavilySearch
|
|
37
41
|
|
|
38
42
|
if not os.environ.get("TAVILY_API_KEY"):
|
|
39
|
-
|
|
43
|
+
if tool_config.api_key:
|
|
44
|
+
os.environ["TAVILY_API_KEY"] = get_secret_value(tool_config.api_key)
|
|
40
45
|
# This tavily tool requires an API Key and it must be set as an environment variable (TAVILY_API_KEY)
|
|
41
46
|
# Refer to create_customize_workflow.md for instructions of getting the API key
|
|
42
47
|
|
{nvidia_nat_langchain-1.3.0rc5.dist-info → nvidia_nat_langchain-1.4.0a20251216.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nvidia-nat-langchain
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0a20251216
|
|
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,8 @@ 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.
|
|
19
|
+
Requires-Dist: nvidia-nat==v1.4.0a20251216
|
|
20
|
+
Requires-Dist: langchain~=0.3.27
|
|
20
21
|
Requires-Dist: langchain-aws~=0.2.31
|
|
21
22
|
Requires-Dist: langchain-core~=0.3.75
|
|
22
23
|
Requires-Dist: langchain-litellm~=0.2.3
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
nat/meta/pypi.md,sha256=T_KFtTXVxhFM8Y6K3OlNByA5sTXLQuqqUpHgNOCvZBU,1120
|
|
2
|
+
nat/plugins/langchain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
nat/plugins/langchain/embedder.py,sha256=Ie-J4N4lvygW0zNKklKZVSYxYFcRW6p_QlRdcz0WxcE,3607
|
|
4
|
+
nat/plugins/langchain/llm.py,sha256=FaEPleu_aBCsQ-6tt3ofr1A2Oa_ta60tMb0yGGhiWSo,8561
|
|
5
|
+
nat/plugins/langchain/register.py,sha256=jgq6wSJoGQIZFJhS8RbUs25cLgNJjCkFu4M6qaWJS_4,906
|
|
6
|
+
nat/plugins/langchain/retriever.py,sha256=SWbXXOezEUuPACnmSSU497NAmEVEMj2SrFJGodkRg34,2644
|
|
7
|
+
nat/plugins/langchain/tool_wrapper.py,sha256=Zgb2_XB4bEhjPPeqS-ZH_OJT_pcQmteX7u03N_qCLfc,2121
|
|
8
|
+
nat/plugins/langchain/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
nat/plugins/langchain/tools/code_generation_tool.py,sha256=f5pna0WMOx3QOS4WnaMFKD7tBZ1-tS0PfI0IMYobtTQ,2723
|
|
10
|
+
nat/plugins/langchain/tools/register.py,sha256=uemxqLxcNk1bGX4crV52oMphLTZWonStzkXwTZeG2Rw,889
|
|
11
|
+
nat/plugins/langchain/tools/tavily_internet_search.py,sha256=W5sdZ9hobPc3xbnWPSbtFBClIn14EM8xT0XUVF2HpWo,2928
|
|
12
|
+
nat/plugins/langchain/tools/wikipedia_search.py,sha256=431YwLsjoC_mdvMZ_gY0Q37Uqaue2ASnAHpwr4jWCaU,2197
|
|
13
|
+
nvidia_nat_langchain-1.4.0a20251216.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
|
|
14
|
+
nvidia_nat_langchain-1.4.0a20251216.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
15
|
+
nvidia_nat_langchain-1.4.0a20251216.dist-info/METADATA,sha256=RbqeB8fHZdx2VKxjL9gxJkgyeeu6njb_k7_8ES9H6F4,2263
|
|
16
|
+
nvidia_nat_langchain-1.4.0a20251216.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
17
|
+
nvidia_nat_langchain-1.4.0a20251216.dist-info/entry_points.txt,sha256=4deXsMn97I012HhDw0UjoqcZ8eEoZ7BnqaRx5QmzebY,123
|
|
18
|
+
nvidia_nat_langchain-1.4.0a20251216.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
|
|
19
|
+
nvidia_nat_langchain-1.4.0a20251216.dist-info/RECORD,,
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
nat/meta/pypi.md,sha256=T_KFtTXVxhFM8Y6K3OlNByA5sTXLQuqqUpHgNOCvZBU,1120
|
|
2
|
-
nat/plugins/langchain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
nat/plugins/langchain/embedder.py,sha256=ZSESaazyz7y3F0GSSsWRe_xfvxOe0Mwd45wEAkQ2jJk,3339
|
|
4
|
-
nat/plugins/langchain/llm.py,sha256=KFE59qGeYxTSScaPgid5CDcx_acTcAJylmDVAmQtYmk,7089
|
|
5
|
-
nat/plugins/langchain/register.py,sha256=jgq6wSJoGQIZFJhS8RbUs25cLgNJjCkFu4M6qaWJS_4,906
|
|
6
|
-
nat/plugins/langchain/retriever.py,sha256=SWbXXOezEUuPACnmSSU497NAmEVEMj2SrFJGodkRg34,2644
|
|
7
|
-
nat/plugins/langchain/tool_wrapper.py,sha256=Zgb2_XB4bEhjPPeqS-ZH_OJT_pcQmteX7u03N_qCLfc,2121
|
|
8
|
-
nat/plugins/langchain/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
nat/plugins/langchain/tools/code_generation_tool.py,sha256=f5pna0WMOx3QOS4WnaMFKD7tBZ1-tS0PfI0IMYobtTQ,2723
|
|
10
|
-
nat/plugins/langchain/tools/register.py,sha256=uemxqLxcNk1bGX4crV52oMphLTZWonStzkXwTZeG2Rw,889
|
|
11
|
-
nat/plugins/langchain/tools/tavily_internet_search.py,sha256=UFMP1xh_kC3fydMQBeV-oDZ-M7jnLcs5OkMSzgm7mng,2653
|
|
12
|
-
nat/plugins/langchain/tools/wikipedia_search.py,sha256=431YwLsjoC_mdvMZ_gY0Q37Uqaue2ASnAHpwr4jWCaU,2197
|
|
13
|
-
nvidia_nat_langchain-1.3.0rc5.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
|
|
14
|
-
nvidia_nat_langchain-1.3.0rc5.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
15
|
-
nvidia_nat_langchain-1.3.0rc5.dist-info/METADATA,sha256=-_pFFAFrfRak1eShZ6ZnzbHQwrtCOJiTHZLDr47xQfA,2219
|
|
16
|
-
nvidia_nat_langchain-1.3.0rc5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
17
|
-
nvidia_nat_langchain-1.3.0rc5.dist-info/entry_points.txt,sha256=4deXsMn97I012HhDw0UjoqcZ8eEoZ7BnqaRx5QmzebY,123
|
|
18
|
-
nvidia_nat_langchain-1.3.0rc5.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
|
|
19
|
-
nvidia_nat_langchain-1.3.0rc5.dist-info/RECORD,,
|
{nvidia_nat_langchain-1.3.0rc5.dist-info → nvidia_nat_langchain-1.4.0a20251216.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|