nvidia-nat 1.3.0a20250917__py3-none-any.whl → 1.3.0a20250923__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.
Files changed (40) hide show
  1. nat/agent/react_agent/register.py +3 -10
  2. nat/agent/reasoning_agent/reasoning_agent.py +3 -6
  3. nat/agent/register.py +0 -1
  4. nat/agent/rewoo_agent/agent.py +6 -1
  5. nat/agent/rewoo_agent/register.py +9 -10
  6. nat/agent/tool_calling_agent/register.py +3 -10
  7. nat/authentication/credential_validator/__init__.py +14 -0
  8. nat/authentication/credential_validator/bearer_token_validator.py +557 -0
  9. nat/authentication/oauth2/oauth2_resource_server_config.py +124 -0
  10. nat/builder/context.py +28 -6
  11. nat/builder/function.py +165 -19
  12. nat/builder/workflow_builder.py +2 -0
  13. nat/cli/entrypoint.py +2 -9
  14. nat/control_flow/register.py +20 -0
  15. nat/control_flow/router_agent/__init__.py +0 -0
  16. nat/{agent → control_flow}/router_agent/agent.py +3 -3
  17. nat/{agent → control_flow}/router_agent/register.py +8 -14
  18. nat/control_flow/sequential_executor.py +167 -0
  19. nat/data_models/agent.py +34 -0
  20. nat/data_models/authentication.py +38 -0
  21. nat/front_ends/fastapi/dask_client_mixin.py +26 -4
  22. nat/front_ends/fastapi/fastapi_front_end_config.py +4 -0
  23. nat/front_ends/fastapi/fastapi_front_end_plugin.py +30 -7
  24. nat/front_ends/mcp/introspection_token_verifier.py +73 -0
  25. nat/front_ends/mcp/mcp_front_end_config.py +5 -1
  26. nat/front_ends/mcp/mcp_front_end_plugin.py +37 -11
  27. nat/front_ends/mcp/mcp_front_end_plugin_worker.py +108 -1
  28. nat/front_ends/mcp/tool_converter.py +3 -0
  29. nat/observability/mixin/type_introspection_mixin.py +19 -0
  30. nat/profiler/parameter_optimization/parameter_optimizer.py +5 -1
  31. nat/utils/log_levels.py +25 -0
  32. {nvidia_nat-1.3.0a20250917.dist-info → nvidia_nat-1.3.0a20250923.dist-info}/METADATA +3 -1
  33. {nvidia_nat-1.3.0a20250917.dist-info → nvidia_nat-1.3.0a20250923.dist-info}/RECORD +40 -31
  34. {nvidia_nat-1.3.0a20250917.dist-info → nvidia_nat-1.3.0a20250923.dist-info}/entry_points.txt +1 -0
  35. /nat/{agent/router_agent → control_flow}/__init__.py +0 -0
  36. /nat/{agent → control_flow}/router_agent/prompt.py +0 -0
  37. {nvidia_nat-1.3.0a20250917.dist-info → nvidia_nat-1.3.0a20250923.dist-info}/WHEEL +0 -0
  38. {nvidia_nat-1.3.0a20250917.dist-info → nvidia_nat-1.3.0a20250923.dist-info}/licenses/LICENSE-3rd-party.txt +0 -0
  39. {nvidia_nat-1.3.0a20250917.dist-info → nvidia_nat-1.3.0a20250923.dist-info}/licenses/LICENSE.md +0 -0
  40. {nvidia_nat-1.3.0a20250917.dist-info → nvidia_nat-1.3.0a20250923.dist-info}/top_level.txt +0 -0
@@ -17,18 +17,16 @@ import logging
17
17
 
18
18
  from pydantic import AliasChoices
19
19
  from pydantic import Field
20
- from pydantic import PositiveInt
21
20
 
22
21
  from nat.builder.builder import Builder
23
22
  from nat.builder.framework_enum import LLMFrameworkEnum
24
23
  from nat.builder.function_info import FunctionInfo
25
24
  from nat.cli.register_workflow import register_function
25
+ from nat.data_models.agent import AgentBaseConfig
26
26
  from nat.data_models.api_server import ChatRequest
27
27
  from nat.data_models.api_server import ChatResponse
28
28
  from nat.data_models.component_ref import FunctionGroupRef
29
29
  from nat.data_models.component_ref import FunctionRef
30
- from nat.data_models.component_ref import LLMRef
31
- from nat.data_models.function import FunctionBaseConfig
32
30
  from nat.data_models.optimizable import OptimizableField
33
31
  from nat.data_models.optimizable import OptimizableMixin
34
32
  from nat.data_models.optimizable import SearchSpace
@@ -37,16 +35,14 @@ from nat.utils.type_converter import GlobalTypeConverter
37
35
  logger = logging.getLogger(__name__)
38
36
 
39
37
 
40
- class ReActAgentWorkflowConfig(FunctionBaseConfig, OptimizableMixin, name="react_agent"):
38
+ class ReActAgentWorkflowConfig(AgentBaseConfig, OptimizableMixin, name="react_agent"):
41
39
  """
42
40
  Defines a NAT function that uses a ReAct Agent performs reasoning inbetween tool calls, and utilizes the
43
41
  tool names and descriptions to select the optimal tool.
44
42
  """
45
-
43
+ description: str = Field(default="ReAct Agent Workflow", description="The description of this functions use.")
46
44
  tool_names: list[FunctionRef | FunctionGroupRef] = Field(
47
45
  default_factory=list, description="The list of tools to provide to the react agent.")
48
- llm_name: LLMRef = Field(description="The LLM model to use with the react agent.")
49
- verbose: bool = Field(default=False, description="Set the verbosity of the react agent's logging.")
50
46
  retry_agent_response_parsing_errors: bool = Field(
51
47
  default=True,
52
48
  validation_alias=AliasChoices("retry_agent_response_parsing_errors", "retry_parsing_errors"),
@@ -65,7 +61,6 @@ class ReActAgentWorkflowConfig(FunctionBaseConfig, OptimizableMixin, name="react
65
61
  description="Whether to pass tool call errors to agent. If False, failed tool calls will raise an exception.")
66
62
  include_tool_input_schema_in_tool_description: bool = Field(
67
63
  default=True, description="Specify inclusion of tool input schemas in the prompt.")
68
- description: str = Field(default="ReAct Agent Workflow", description="The description of this functions use.")
69
64
  normalize_tool_input_quotes: bool = Field(
70
65
  default=True,
71
66
  description="Whether to replace single quotes with double quotes in the tool input. "
@@ -74,8 +69,6 @@ class ReActAgentWorkflowConfig(FunctionBaseConfig, OptimizableMixin, name="react
74
69
  default=None,
75
70
  description="Provides the SYSTEM_PROMPT to use with the agent") # defaults to SYSTEM_PROMPT in prompt.py
76
71
  max_history: int = Field(default=15, description="Maximum number of messages to keep in the conversation history.")
77
- log_response_max_chars: PositiveInt = Field(
78
- default=1000, description="Maximum number of characters to display in logs when logging tool responses.")
79
72
  use_openai_api: bool = Field(default=False,
80
73
  description=("Use OpenAI API for the input/output types to the function. "
81
74
  "If False, strings will be used."))
@@ -23,25 +23,22 @@ from nat.builder.builder import Builder
23
23
  from nat.builder.framework_enum import LLMFrameworkEnum
24
24
  from nat.builder.function_info import FunctionInfo
25
25
  from nat.cli.register_workflow import register_function
26
+ from nat.data_models.agent import AgentBaseConfig
26
27
  from nat.data_models.api_server import ChatRequest
27
28
  from nat.data_models.component_ref import FunctionRef
28
- from nat.data_models.component_ref import LLMRef
29
- from nat.data_models.function import FunctionBaseConfig
30
29
 
31
30
  logger = logging.getLogger(__name__)
32
31
 
33
32
 
34
- class ReasoningFunctionConfig(FunctionBaseConfig, name="reasoning_agent"):
33
+ class ReasoningFunctionConfig(AgentBaseConfig, name="reasoning_agent"):
35
34
  """
36
35
  Defines a NAT function that performs reasoning on the input data.
37
36
  Output is passed to the next function in the workflow.
38
37
 
39
38
  Designed to be used with an InterceptingFunction.
40
39
  """
41
-
42
- llm_name: LLMRef = Field(description="The name of the LLM to use for reasoning.")
40
+ description: str = Field(default="Reasoning Agent", description="The description of this function's use.")
43
41
  augmented_fn: FunctionRef = Field(description="The name of the function to reason on.")
44
- verbose: bool = Field(default=False, description="Whether to log detailed information.")
45
42
  reasoning_prompt_template: str = Field(
46
43
  default=("You are an expert reasoning model task with creating a detailed execution plan"
47
44
  " for a system that has the following description:\n\n"
nat/agent/register.py CHANGED
@@ -20,5 +20,4 @@ from .prompt_optimizer import register as prompt_optimizer
20
20
  from .react_agent import register as react_agent
21
21
  from .reasoning_agent import reasoning_agent
22
22
  from .rewoo_agent import register as rewoo_agent
23
- from .router_agent import register as router_agent
24
23
  from .tool_calling_agent import register as tool_calling_agent
@@ -69,7 +69,8 @@ class ReWOOAgentGraph(BaseAgent):
69
69
  callbacks: list[AsyncCallbackHandler] | None = None,
70
70
  detailed_logs: bool = False,
71
71
  log_response_max_chars: int = 1000,
72
- tool_call_max_retries: int = 3):
72
+ tool_call_max_retries: int = 3,
73
+ raise_tool_call_error: bool = True):
73
74
  super().__init__(llm=llm,
74
75
  tools=tools,
75
76
  callbacks=callbacks,
@@ -96,6 +97,7 @@ class ReWOOAgentGraph(BaseAgent):
96
97
  self.solver_prompt = solver_prompt
97
98
  self.tools_dict = {tool.name: tool for tool in tools}
98
99
  self.tool_call_max_retries = tool_call_max_retries
100
+ self.raise_tool_call_error = raise_tool_call_error
99
101
 
100
102
  logger.debug("%s Initialized ReWOO Agent Graph", AGENT_LOG_PREFIX)
101
103
 
@@ -276,6 +278,9 @@ class ReWOOAgentGraph(BaseAgent):
276
278
  if self.detailed_logs:
277
279
  self._log_tool_response(requested_tool.name, tool_input_parsed, str(tool_response))
278
280
 
281
+ if self.raise_tool_call_error and tool_response.status == "error":
282
+ raise RuntimeError(f"Tool call failed: {tool_response.content}")
283
+
279
284
  intermediate_results[placeholder] = tool_response
280
285
  return {"intermediate_results": intermediate_results}
281
286
 
@@ -23,30 +23,26 @@ from nat.builder.builder import Builder
23
23
  from nat.builder.framework_enum import LLMFrameworkEnum
24
24
  from nat.builder.function_info import FunctionInfo
25
25
  from nat.cli.register_workflow import register_function
26
+ from nat.data_models.agent import AgentBaseConfig
26
27
  from nat.data_models.api_server import ChatRequest
27
28
  from nat.data_models.api_server import ChatResponse
28
29
  from nat.data_models.component_ref import FunctionGroupRef
29
30
  from nat.data_models.component_ref import FunctionRef
30
- from nat.data_models.component_ref import LLMRef
31
- from nat.data_models.function import FunctionBaseConfig
32
31
  from nat.utils.type_converter import GlobalTypeConverter
33
32
 
34
33
  logger = logging.getLogger(__name__)
35
34
 
36
35
 
37
- class ReWOOAgentWorkflowConfig(FunctionBaseConfig, name="rewoo_agent"):
36
+ class ReWOOAgentWorkflowConfig(AgentBaseConfig, name="rewoo_agent"):
38
37
  """
39
38
  Defines a NAT function that uses a ReWOO Agent performs reasoning inbetween tool calls, and utilizes the
40
39
  tool names and descriptions to select the optimal tool.
41
40
  """
42
-
41
+ description: str = Field(default="ReWOO Agent Workflow", description="The description of this functions use.")
43
42
  tool_names: list[FunctionRef | FunctionGroupRef] = Field(
44
43
  default_factory=list, description="The list of tools to provide to the rewoo agent.")
45
- llm_name: LLMRef = Field(description="The LLM model to use with the rewoo agent.")
46
- verbose: bool = Field(default=False, description="Set the verbosity of the rewoo agent's logging.")
47
44
  include_tool_input_schema_in_tool_description: bool = Field(
48
45
  default=True, description="Specify inclusion of tool input schemas in the prompt.")
49
- description: str = Field(default="ReWOO Agent Workflow", description="The description of this functions use.")
50
46
  planner_prompt: str | None = Field(
51
47
  default=None,
52
48
  description="Provides the PLANNER_PROMPT to use with the agent") # defaults to PLANNER_PROMPT in prompt.py
@@ -57,8 +53,6 @@ class ReWOOAgentWorkflowConfig(FunctionBaseConfig, name="rewoo_agent"):
57
53
  description="The number of retries before raising a tool call error.",
58
54
  ge=1)
59
55
  max_history: int = Field(default=15, description="Maximum number of messages to keep in the conversation history.")
60
- log_response_max_chars: PositiveInt = Field(
61
- default=1000, description="Maximum number of characters to display in logs when logging tool responses.")
62
56
  use_openai_api: bool = Field(default=False,
63
57
  description=("Use OpenAI API for the input/output types to the function. "
64
58
  "If False, strings will be used."))
@@ -69,6 +63,10 @@ class ReWOOAgentWorkflowConfig(FunctionBaseConfig, name="rewoo_agent"):
69
63
  additional_solver_instructions: str | None = Field(
70
64
  default=None,
71
65
  description="Additional instructions to provide to the agent in addition to the base solver prompt.")
66
+ raise_tool_call_error: bool = Field(default=True,
67
+ description="Whether to raise a exception immediately if a tool"
68
+ "call fails. If set to False, the tool call error message will be included in"
69
+ "the tool response and passed to the next tool.")
72
70
 
73
71
 
74
72
  @register_function(config_type=ReWOOAgentWorkflowConfig, framework_wrappers=[LLMFrameworkEnum.LANGCHAIN])
@@ -123,7 +121,8 @@ async def rewoo_agent_workflow(config: ReWOOAgentWorkflowConfig, builder: Builde
123
121
  use_tool_schema=config.include_tool_input_schema_in_tool_description,
124
122
  detailed_logs=config.verbose,
125
123
  log_response_max_chars=config.log_response_max_chars,
126
- tool_call_max_retries=config.tool_call_max_retries).build_graph()
124
+ tool_call_max_retries=config.tool_call_max_retries,
125
+ raise_tool_call_error=config.raise_tool_call_error).build_graph()
127
126
 
128
127
  async def _response_fn(input_message: ChatRequest) -> ChatResponse:
129
128
  try:
@@ -16,35 +16,28 @@
16
16
  import logging
17
17
 
18
18
  from pydantic import Field
19
- from pydantic import PositiveInt
20
19
 
21
20
  from nat.builder.builder import Builder
22
21
  from nat.builder.framework_enum import LLMFrameworkEnum
23
22
  from nat.builder.function_info import FunctionInfo
24
23
  from nat.cli.register_workflow import register_function
24
+ from nat.data_models.agent import AgentBaseConfig
25
25
  from nat.data_models.component_ref import FunctionGroupRef
26
26
  from nat.data_models.component_ref import FunctionRef
27
- from nat.data_models.component_ref import LLMRef
28
- from nat.data_models.function import FunctionBaseConfig
29
27
 
30
28
  logger = logging.getLogger(__name__)
31
29
 
32
30
 
33
- class ToolCallAgentWorkflowConfig(FunctionBaseConfig, name="tool_calling_agent"):
31
+ class ToolCallAgentWorkflowConfig(AgentBaseConfig, name="tool_calling_agent"):
34
32
  """
35
33
  A Tool Calling Agent requires an LLM which supports tool calling. A tool Calling Agent utilizes the tool
36
34
  input parameters to select the optimal tool. Supports handling tool errors.
37
35
  """
38
-
36
+ description: str = Field(default="Tool Calling Agent Workflow", description="Description of this functions use.")
39
37
  tool_names: list[FunctionRef | FunctionGroupRef] = Field(
40
38
  default_factory=list, description="The list of tools to provide to the tool calling agent.")
41
- llm_name: LLMRef = Field(description="The LLM model to use with the tool calling agent.")
42
- verbose: bool = Field(default=False, description="Set the verbosity of the tool calling agent's logging.")
43
39
  handle_tool_errors: bool = Field(default=True, description="Specify ability to handle tool calling errors.")
44
- description: str = Field(default="Tool Calling Agent Workflow", description="Description of this functions use.")
45
40
  max_iterations: int = Field(default=15, description="Number of tool calls before stoping the tool calling agent.")
46
- log_response_max_chars: PositiveInt = Field(
47
- default=1000, description="Maximum number of characters to display in logs when logging tool responses.")
48
41
  system_prompt: str | None = Field(default=None, description="Provides the system prompt to use with the agent.")
49
42
  additional_instructions: str | None = Field(default=None,
50
43
  description="Additional instructions appended to the system prompt.")
@@ -0,0 +1,14 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.