nvidia-nat 1.2.0a20250813__py3-none-any.whl → 1.2.0rc6__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/agent/react_agent/register.py +1 -1
- nat/agent/reasoning_agent/reasoning_agent.py +3 -3
- nat/agent/rewoo_agent/prompt.py +11 -12
- nat/agent/rewoo_agent/register.py +30 -32
- nat/authentication/http_basic_auth/http_basic_auth_provider.py +1 -1
- nat/authentication/interfaces.py +1 -1
- nat/authentication/oauth2/oauth2_auth_code_flow_provider.py +2 -2
- nat/builder/component_utils.py +5 -5
- nat/builder/context.py +5 -5
- nat/builder/front_end.py +6 -6
- nat/builder/function_base.py +4 -4
- nat/builder/function_info.py +1 -1
- nat/builder/intermediate_step_manager.py +4 -4
- nat/builder/user_interaction_manager.py +3 -3
- nat/builder/workflow_builder.py +2 -2
- nat/cli/cli_utils/validation.py +1 -1
- nat/cli/commands/configure/channel/add.py +1 -1
- nat/cli/commands/configure/channel/channel.py +1 -3
- nat/cli/commands/configure/channel/remove.py +1 -1
- nat/cli/commands/configure/channel/update.py +1 -1
- nat/cli/commands/configure/configure.py +2 -2
- nat/cli/commands/evaluate.py +1 -1
- nat/cli/commands/info/info.py +2 -4
- nat/cli/commands/info/list_components.py +2 -2
- nat/cli/commands/info/list_mcp.py +9 -9
- nat/cli/commands/registry/publish.py +3 -3
- nat/cli/commands/registry/pull.py +3 -3
- nat/cli/commands/registry/registry.py +1 -3
- nat/cli/commands/registry/remove.py +3 -3
- nat/cli/commands/registry/search.py +3 -3
- nat/cli/commands/start.py +4 -4
- nat/cli/commands/workflow/templates/pyproject.toml.j2 +4 -4
- nat/cli/commands/workflow/workflow_commands.py +6 -6
- nat/data_models/api_server.py +38 -31
- nat/data_models/component_ref.py +9 -9
- nat/data_models/dataset_handler.py +56 -10
- nat/data_models/discovery_metadata.py +21 -50
- nat/data_models/evaluate.py +2 -2
- nat/data_models/intermediate_step.py +4 -4
- nat/embedder/register.py +0 -2
- nat/eval/dataset_handler/dataset_handler.py +118 -5
- nat/eval/evaluate.py +1 -1
- nat/eval/evaluator/evaluator_model.py +3 -3
- nat/eval/rag_evaluator/evaluate.py +1 -1
- nat/eval/swe_bench_evaluator/evaluate.py +2 -2
- nat/experimental/test_time_compute/editing/motivation_aware_summarization.py +1 -1
- nat/experimental/test_time_compute/functions/plan_select_execute_function.py +4 -4
- nat/experimental/test_time_compute/functions/ttc_tool_wrapper_function.py +1 -1
- nat/experimental/test_time_compute/scoring/llm_based_agent_scorer.py +1 -1
- nat/experimental/test_time_compute/scoring/llm_based_plan_scorer.py +1 -1
- nat/experimental/test_time_compute/search/multi_llm_planner.py +1 -1
- nat/experimental/test_time_compute/search/multi_query_retrieval_search.py +1 -1
- nat/experimental/test_time_compute/search/single_shot_multi_plan_planner.py +1 -1
- nat/experimental/test_time_compute/selection/llm_based_agent_output_selector.py +1 -1
- nat/experimental/test_time_compute/selection/llm_based_output_merging_selector.py +1 -1
- nat/experimental/test_time_compute/selection/llm_based_plan_selector.py +1 -1
- nat/front_ends/console/console_front_end_config.py +1 -1
- nat/front_ends/fastapi/fastapi_front_end_config.py +6 -7
- nat/front_ends/fastapi/fastapi_front_end_plugin.py +4 -4
- nat/front_ends/fastapi/fastapi_front_end_plugin_worker.py +13 -13
- nat/front_ends/fastapi/intermediate_steps_subscriber.py +1 -1
- nat/front_ends/fastapi/main.py +6 -6
- nat/front_ends/fastapi/message_handler.py +14 -3
- nat/front_ends/fastapi/message_validator.py +6 -8
- nat/front_ends/fastapi/response_helpers.py +3 -3
- nat/front_ends/mcp/mcp_front_end_config.py +3 -2
- nat/front_ends/mcp/mcp_front_end_plugin_worker.py +4 -4
- nat/front_ends/mcp/tool_converter.py +15 -16
- nat/memory/__init__.py +2 -2
- nat/meta/pypi.md +8 -8
- nat/object_store/__init__.py +2 -2
- nat/observability/exporter/base_exporter.py +1 -1
- nat/observability/exporter/raw_exporter.py +1 -1
- nat/observability/exporter_manager.py +1 -1
- nat/profiler/callbacks/agno_callback_handler.py +4 -4
- nat/profiler/callbacks/llama_index_callback_handler.py +2 -2
- nat/profiler/callbacks/semantic_kernel_callback_handler.py +1 -1
- nat/profiler/decorators/function_tracking.py +1 -1
- nat/profiler/forecasting/models/linear_model.py +3 -2
- nat/profiler/forecasting/models/random_forest_regressor.py +3 -2
- nat/profiler/inference_optimization/bottleneck_analysis/nested_stack_analysis.py +1 -1
- nat/profiler/inference_optimization/experimental/prefix_span_analysis.py +1 -1
- nat/profiler/profile_runner.py +1 -1
- nat/registry_handlers/local/local_handler.py +5 -5
- nat/registry_handlers/local/register_local.py +1 -1
- nat/registry_handlers/package_utils.py +17 -17
- nat/registry_handlers/pypi/pypi_handler.py +5 -5
- nat/registry_handlers/pypi/register_pypi.py +3 -3
- nat/registry_handlers/registry_handler_base.py +8 -8
- nat/registry_handlers/rest/register_rest.py +4 -4
- nat/registry_handlers/rest/rest_handler.py +6 -6
- nat/registry_handlers/schemas/package.py +3 -3
- nat/registry_handlers/schemas/publish.py +4 -4
- nat/registry_handlers/schemas/pull.py +4 -4
- nat/registry_handlers/schemas/search.py +7 -7
- nat/runtime/loader.py +21 -20
- nat/runtime/runner.py +2 -2
- nat/runtime/session.py +1 -1
- nat/settings/global_settings.py +2 -2
- nat/tool/chat_completion.py +1 -1
- nat/tool/code_execution/README.md +2 -2
- nat/tool/code_execution/test_code_execution_sandbox.py +1 -1
- nat/tool/mcp/exceptions.py +1 -1
- nat/tool/mcp/mcp_tool.py +1 -1
- nat/tool/retriever.py +3 -3
- nat/tool/server_tools.py +11 -11
- nat/utils/settings/global_settings.py +1 -1
- {nvidia_nat-1.2.0a20250813.dist-info → nvidia_nat-1.2.0rc6.dist-info}/METADATA +9 -9
- {nvidia_nat-1.2.0a20250813.dist-info → nvidia_nat-1.2.0rc6.dist-info}/RECORD +114 -116
- nat/embedder/langchain_client.py +0 -41
- nat/meta/module_to_distro.json +0 -4
- {nvidia_nat-1.2.0a20250813.dist-info → nvidia_nat-1.2.0rc6.dist-info}/WHEEL +0 -0
- {nvidia_nat-1.2.0a20250813.dist-info → nvidia_nat-1.2.0rc6.dist-info}/entry_points.txt +0 -0
- {nvidia_nat-1.2.0a20250813.dist-info → nvidia_nat-1.2.0rc6.dist-info}/licenses/LICENSE-3rd-party.txt +0 -0
- {nvidia_nat-1.2.0a20250813.dist-info → nvidia_nat-1.2.0rc6.dist-info}/licenses/LICENSE.md +0 -0
- {nvidia_nat-1.2.0a20250813.dist-info → nvidia_nat-1.2.0rc6.dist-info}/top_level.txt +0 -0
|
@@ -34,7 +34,7 @@ logger = logging.getLogger(__name__)
|
|
|
34
34
|
|
|
35
35
|
class ReActAgentWorkflowConfig(FunctionBaseConfig, name="react_agent"):
|
|
36
36
|
"""
|
|
37
|
-
Defines
|
|
37
|
+
Defines a NAT function that uses a ReAct Agent performs reasoning inbetween tool calls, and utilizes the
|
|
38
38
|
tool names and descriptions to select the optimal tool.
|
|
39
39
|
"""
|
|
40
40
|
|
|
@@ -33,7 +33,7 @@ logger = logging.getLogger(__name__)
|
|
|
33
33
|
|
|
34
34
|
class ReasoningFunctionConfig(FunctionBaseConfig, name="reasoning_agent"):
|
|
35
35
|
"""
|
|
36
|
-
Defines
|
|
36
|
+
Defines a NAT function that performs reasoning on the input data.
|
|
37
37
|
Output is passed to the next function in the workflow.
|
|
38
38
|
|
|
39
39
|
Designed to be used with an InterceptingFunction.
|
|
@@ -140,7 +140,7 @@ async def build_reasoning_function(config: ReasoningFunctionConfig, builder: Bui
|
|
|
140
140
|
Perform reasoning on the input text.
|
|
141
141
|
|
|
142
142
|
Args:
|
|
143
|
-
input_message (
|
|
143
|
+
input_message (ChatRequest): The input text to reason on.
|
|
144
144
|
"""
|
|
145
145
|
|
|
146
146
|
input_text = "".join([str(message.model_dump()) + "\n" for message in input_message.messages])
|
|
@@ -183,7 +183,7 @@ async def build_reasoning_function(config: ReasoningFunctionConfig, builder: Bui
|
|
|
183
183
|
Perform reasoning on the input text.
|
|
184
184
|
|
|
185
185
|
Args:
|
|
186
|
-
input_message (
|
|
186
|
+
input_message (ChatRequest): The input text to reason on.
|
|
187
187
|
"""
|
|
188
188
|
|
|
189
189
|
input_text = "".join([str(message.model_dump()) + "\n" for message in input_message.messages])
|
nat/agent/rewoo_agent/prompt.py
CHANGED
|
@@ -13,9 +13,6 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
|
-
# flake8: noqa
|
|
17
|
-
from langchain_core.prompts.chat import ChatPromptTemplate
|
|
18
|
-
|
|
19
16
|
PLANNER_SYSTEM_PROMPT = """
|
|
20
17
|
For the following task, make plans that can solve the problem step by step. For each plan, indicate \
|
|
21
18
|
which external tool together with tool input to retrieve evidence. You can store the evidence into a \
|
|
@@ -29,19 +26,25 @@ The tools should be one of the following: [{tool_names}]
|
|
|
29
26
|
|
|
30
27
|
You are not required to use all the tools listed. Choose only the ones that best fit the needs of each plan step.
|
|
31
28
|
|
|
32
|
-
Your output must be a JSON array where each element represents one planning step. Each step must be an object with
|
|
29
|
+
Your output must be a JSON array where each element represents one planning step. Each step must be an object with
|
|
30
|
+
|
|
31
|
+
exactly two keys:
|
|
33
32
|
|
|
34
33
|
1. "plan": A string that describes in detail the action or reasoning for that step.
|
|
35
34
|
|
|
36
|
-
2. "evidence": An object representing the external tool call associated with that plan step. This object must have the
|
|
35
|
+
2. "evidence": An object representing the external tool call associated with that plan step. This object must have the
|
|
36
|
+
following keys:
|
|
37
37
|
|
|
38
|
-
-"placeholder": A string that identifies the evidence placeholder (e.g., "#E1", "#E2", etc.). The numbering should
|
|
38
|
+
-"placeholder": A string that identifies the evidence placeholder (e.g., "#E1", "#E2", etc.). The numbering should
|
|
39
|
+
be sequential based on the order of steps.
|
|
39
40
|
|
|
40
41
|
-"tool": A string specifying the name of the external tool used.
|
|
41
42
|
|
|
42
|
-
-"tool_input": The input to the tool. This can be a string, array, or object, depending on the requirements of the
|
|
43
|
+
-"tool_input": The input to the tool. This can be a string, array, or object, depending on the requirements of the
|
|
44
|
+
tool.
|
|
43
45
|
|
|
44
|
-
Do not include any additional keys or characters in your output, and do not wrap your response with markdown formatting.
|
|
46
|
+
Do not include any additional keys or characters in your output, and do not wrap your response with markdown formatting.
|
|
47
|
+
Your output must be strictly valid JSON.
|
|
45
48
|
|
|
46
49
|
Important instructions:
|
|
47
50
|
|
|
@@ -87,8 +90,6 @@ PLANNER_USER_PROMPT = """
|
|
|
87
90
|
task: {task}
|
|
88
91
|
"""
|
|
89
92
|
|
|
90
|
-
rewoo_planner_prompt = ChatPromptTemplate([("system", PLANNER_SYSTEM_PROMPT), ("user", PLANNER_USER_PROMPT)])
|
|
91
|
-
|
|
92
93
|
SOLVER_SYSTEM_PROMPT = """
|
|
93
94
|
Solve the following task or problem. To solve the problem, we have made step-by-step Plan and \
|
|
94
95
|
retrieved corresponding Evidence to each Plan. Use them with caution since long evidence might \
|
|
@@ -104,5 +105,3 @@ task: {task}
|
|
|
104
105
|
|
|
105
106
|
Response:
|
|
106
107
|
"""
|
|
107
|
-
|
|
108
|
-
rewoo_solver_prompt = ChatPromptTemplate([("system", SOLVER_SYSTEM_PROMPT), ("user", SOLVER_USER_PROMPT)])
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
import logging
|
|
17
17
|
|
|
18
|
+
from pydantic import AliasChoices
|
|
18
19
|
from pydantic import Field
|
|
19
20
|
|
|
20
21
|
from nat.builder.builder import Builder
|
|
@@ -33,7 +34,7 @@ logger = logging.getLogger(__name__)
|
|
|
33
34
|
|
|
34
35
|
class ReWOOAgentWorkflowConfig(FunctionBaseConfig, name="rewoo_agent"):
|
|
35
36
|
"""
|
|
36
|
-
Defines
|
|
37
|
+
Defines a NAT function that uses a ReWOO Agent performs reasoning inbetween tool calls, and utilizes the
|
|
37
38
|
tool names and descriptions to select the optimal tool.
|
|
38
39
|
"""
|
|
39
40
|
|
|
@@ -54,51 +55,48 @@ class ReWOOAgentWorkflowConfig(FunctionBaseConfig, name="rewoo_agent"):
|
|
|
54
55
|
use_openai_api: bool = Field(default=False,
|
|
55
56
|
description=("Use OpenAI API for the input/output types to the function. "
|
|
56
57
|
"If False, strings will be used."))
|
|
57
|
-
|
|
58
|
-
default=None,
|
|
58
|
+
additional_planner_instructions: str | None = Field(
|
|
59
|
+
default=None,
|
|
60
|
+
validation_alias=AliasChoices("additional_planner_instructions", "additional_instructions"),
|
|
61
|
+
description="Additional instructions to provide to the agent in addition to the base planner prompt.")
|
|
62
|
+
additional_solver_instructions: str | None = Field(
|
|
63
|
+
default=None,
|
|
64
|
+
description="Additional instructions to provide to the agent in addition to the base solver prompt.")
|
|
59
65
|
|
|
60
66
|
|
|
61
67
|
@register_function(config_type=ReWOOAgentWorkflowConfig, framework_wrappers=[LLMFrameworkEnum.LANGCHAIN])
|
|
62
|
-
async def
|
|
68
|
+
async def rewoo_agent_workflow(config: ReWOOAgentWorkflowConfig, builder: Builder):
|
|
63
69
|
from langchain.schema import BaseMessage
|
|
64
70
|
from langchain_core.messages import trim_messages
|
|
65
71
|
from langchain_core.messages.human import HumanMessage
|
|
66
72
|
from langchain_core.prompts import ChatPromptTemplate
|
|
67
73
|
from langgraph.graph.graph import CompiledGraph
|
|
68
74
|
|
|
75
|
+
from nat.agent.rewoo_agent.prompt import PLANNER_SYSTEM_PROMPT
|
|
69
76
|
from nat.agent.rewoo_agent.prompt import PLANNER_USER_PROMPT
|
|
77
|
+
from nat.agent.rewoo_agent.prompt import SOLVER_SYSTEM_PROMPT
|
|
70
78
|
from nat.agent.rewoo_agent.prompt import SOLVER_USER_PROMPT
|
|
71
79
|
|
|
72
80
|
from .agent import ReWOOAgentGraph
|
|
73
81
|
from .agent import ReWOOGraphState
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
solver_prompt = config.solver_prompt
|
|
93
|
-
if config.additional_instructions:
|
|
94
|
-
solver_prompt += f"{config.additional_instructions}"
|
|
95
|
-
valid = ReWOOAgentGraph.validate_solver_prompt(config.solver_prompt)
|
|
96
|
-
if not valid:
|
|
97
|
-
logger.exception("Invalid solver_prompt")
|
|
98
|
-
raise ValueError("Invalid solver_prompt")
|
|
99
|
-
solver_prompt = ChatPromptTemplate([("system", config.solver_prompt), ("user", SOLVER_USER_PROMPT)])
|
|
100
|
-
else:
|
|
101
|
-
solver_prompt = rewoo_solver_prompt
|
|
82
|
+
|
|
83
|
+
# the ReWOO Agent prompts are defined in prompt.py, and can be customized there or by modifying the config option
|
|
84
|
+
# planner_prompt and solver_prompt.
|
|
85
|
+
planner_system_prompt = PLANNER_SYSTEM_PROMPT if config.planner_prompt is None else config.planner_prompt
|
|
86
|
+
if config.additional_planner_instructions:
|
|
87
|
+
planner_system_prompt += f"{config.additional_planner_instructions}"
|
|
88
|
+
if not ReWOOAgentGraph.validate_planner_prompt(planner_system_prompt):
|
|
89
|
+
logger.exception("Invalid planner prompt")
|
|
90
|
+
raise ValueError("Invalid planner prompt")
|
|
91
|
+
planner_prompt = ChatPromptTemplate([("system", planner_system_prompt), ("user", PLANNER_USER_PROMPT)])
|
|
92
|
+
|
|
93
|
+
solver_system_prompt = SOLVER_SYSTEM_PROMPT if config.solver_prompt is None else config.solver_prompt
|
|
94
|
+
if config.additional_solver_instructions:
|
|
95
|
+
solver_system_prompt += f"{config.additional_solver_instructions}"
|
|
96
|
+
if not ReWOOAgentGraph.validate_solver_prompt(solver_system_prompt):
|
|
97
|
+
logger.exception("Invalid solver prompt")
|
|
98
|
+
raise ValueError("Invalid solver prompt")
|
|
99
|
+
solver_prompt = ChatPromptTemplate([("system", solver_system_prompt), ("user", SOLVER_USER_PROMPT)])
|
|
102
100
|
|
|
103
101
|
# we can choose an LLM for the ReWOO agent in the config file
|
|
104
102
|
llm = await builder.get_llm(config.llm_name, wrapper_type=LLMFrameworkEnum.LANGCHAIN)
|
|
@@ -47,7 +47,7 @@ class HTTPBasicAuthProvider(AuthProviderBase):
|
|
|
47
47
|
|
|
48
48
|
if user_id is None and hasattr(context, "metadata") and hasattr(
|
|
49
49
|
context.metadata, "cookies") and context.metadata.cookies is not None:
|
|
50
|
-
session_id = context.metadata.cookies.get("
|
|
50
|
+
session_id = context.metadata.cookies.get("nat-session", None)
|
|
51
51
|
if not session_id:
|
|
52
52
|
raise RuntimeError("Authentication failed. No session ID found. Cannot identify user.")
|
|
53
53
|
|
nat/authentication/interfaces.py
CHANGED
|
@@ -75,7 +75,7 @@ class FlowHandlerBase(ABC):
|
|
|
75
75
|
|
|
76
76
|
Each front end will define a FlowHandler that will implement the authenticate method.
|
|
77
77
|
|
|
78
|
-
The `authenticate` method will be stored as the callback in the
|
|
78
|
+
The `authenticate` method will be stored as the callback in the ContextState.user_auth_callback
|
|
79
79
|
"""
|
|
80
80
|
|
|
81
81
|
@abstractmethod
|
|
@@ -65,7 +65,7 @@ class OAuth2AuthCodeFlowProvider(AuthProviderBase[OAuth2AuthCodeFlowProviderConf
|
|
|
65
65
|
async def authenticate(self, user_id: str | None = None) -> AuthResult:
|
|
66
66
|
if user_id is None and hasattr(Context.get(), "metadata") and hasattr(
|
|
67
67
|
Context.get().metadata, "cookies") and Context.get().metadata.cookies is not None:
|
|
68
|
-
session_id = Context.get().metadata.cookies.get("
|
|
68
|
+
session_id = Context.get().metadata.cookies.get("nat-session", None)
|
|
69
69
|
if not session_id:
|
|
70
70
|
raise RuntimeError("Authentication failed. No session ID found. Cannot identify user.")
|
|
71
71
|
|
|
@@ -82,7 +82,7 @@ class OAuth2AuthCodeFlowProvider(AuthProviderBase[OAuth2AuthCodeFlowProviderConf
|
|
|
82
82
|
|
|
83
83
|
auth_callback = self._context.user_auth_callback
|
|
84
84
|
if not auth_callback:
|
|
85
|
-
raise RuntimeError("Authentication callback not set on
|
|
85
|
+
raise RuntimeError("Authentication callback not set on Context.")
|
|
86
86
|
|
|
87
87
|
try:
|
|
88
88
|
authenticated_context = await auth_callback(self.config, AuthFlowType.OAUTH2_AUTHORIZATION_CODE)
|
nat/builder/component_utils.py
CHANGED
|
@@ -56,7 +56,7 @@ class ComponentInstanceData(BaseModel):
|
|
|
56
56
|
"""A data model to hold component runtime instance metadata to support generating build sequences.
|
|
57
57
|
|
|
58
58
|
Args:
|
|
59
|
-
component_group (ComponentGroup): The component group in
|
|
59
|
+
component_group (ComponentGroup): The component group in a NAT configuration object.
|
|
60
60
|
name (ComponentRef): The name of the component runtime instance.
|
|
61
61
|
config (TypedBaseModel): The runtime instance's configuration object.
|
|
62
62
|
instance_id (str): Unique identifier for each runtime instance.
|
|
@@ -166,7 +166,7 @@ def update_dependency_graph(config: "Config", instance_config: TypedBaseModel,
|
|
|
166
166
|
"""Updates the hierarchical component instance dependency graph from a configuration runtime instance.
|
|
167
167
|
|
|
168
168
|
Args:
|
|
169
|
-
config (
|
|
169
|
+
config (Config): A NAT configuration object with runtime instance details.
|
|
170
170
|
instance_config (TypedBaseModel): A component's runtime instance configuration object.
|
|
171
171
|
dependency_graph (nx.DiGraph): A graph tracking runtime instance component dependencies.
|
|
172
172
|
|
|
@@ -196,7 +196,7 @@ def config_to_dependency_objects(config: "Config") -> tuple[dict[str, ComponentI
|
|
|
196
196
|
"""Generates a map of component runtime instance IDs to use when generating a build sequence.
|
|
197
197
|
|
|
198
198
|
Args:
|
|
199
|
-
config (
|
|
199
|
+
config (Config): The NAT workflow configuration object.
|
|
200
200
|
|
|
201
201
|
Returns:
|
|
202
202
|
tuple[dict[str, ComponentInstanceData], nx.DiGraph]: A tuple containing a map of component runtime instance
|
|
@@ -244,10 +244,10 @@ def config_to_dependency_objects(config: "Config") -> tuple[dict[str, ComponentI
|
|
|
244
244
|
|
|
245
245
|
|
|
246
246
|
def build_dependency_sequence(config: "Config") -> list[ComponentInstanceData]:
|
|
247
|
-
"""Generates the depencency sequence from
|
|
247
|
+
"""Generates the depencency sequence from a NAT configuration object
|
|
248
248
|
|
|
249
249
|
Args:
|
|
250
|
-
config (
|
|
250
|
+
config (Config): A NAT configuration object.
|
|
251
251
|
|
|
252
252
|
Returns:
|
|
253
253
|
list[ComponentInstanceData]: A list representing the instatiation sequence to ensure all valid
|
nat/builder/context.py
CHANGED
|
@@ -136,7 +136,7 @@ class Context:
|
|
|
136
136
|
@property
|
|
137
137
|
def user_interaction_manager(self) -> UserInteractionManager:
|
|
138
138
|
"""
|
|
139
|
-
Return an instance of
|
|
139
|
+
Return an instance of UserInteractionManager that uses
|
|
140
140
|
the current context's user_input_callback.
|
|
141
141
|
"""
|
|
142
142
|
return UserInteractionManager(self._context_state)
|
|
@@ -253,13 +253,13 @@ class Context:
|
|
|
253
253
|
@staticmethod
|
|
254
254
|
def get() -> "Context":
|
|
255
255
|
"""
|
|
256
|
-
Static method to retrieve the current
|
|
256
|
+
Static method to retrieve the current Context instance.
|
|
257
257
|
|
|
258
|
-
This method creates and returns an instance of the
|
|
259
|
-
by obtaining the current state from the
|
|
258
|
+
This method creates and returns an instance of the Context class
|
|
259
|
+
by obtaining the current state from the ContextState.
|
|
260
260
|
|
|
261
261
|
Returns:
|
|
262
|
-
|
|
262
|
+
Context: The created Context instance.
|
|
263
263
|
"""
|
|
264
264
|
return Context(ContextState.get())
|
|
265
265
|
|
nat/builder/front_end.py
CHANGED
|
@@ -27,11 +27,11 @@ class FrontEndBase(typing.Generic[FrontEndConfigT], ABC):
|
|
|
27
27
|
|
|
28
28
|
def __init__(self, full_config: "Config"):
|
|
29
29
|
"""
|
|
30
|
-
Initializes the FrontEndBase object with the specified
|
|
30
|
+
Initializes the FrontEndBase object with the specified NAT configuration.
|
|
31
31
|
|
|
32
32
|
Parameters
|
|
33
33
|
----------
|
|
34
|
-
full_config :
|
|
34
|
+
full_config : Config
|
|
35
35
|
The configuration object to use for the front end.
|
|
36
36
|
"""
|
|
37
37
|
|
|
@@ -43,7 +43,7 @@ class FrontEndBase(typing.Generic[FrontEndConfigT], ABC):
|
|
|
43
43
|
@property
|
|
44
44
|
def front_end_config(self) -> FrontEndConfigT:
|
|
45
45
|
"""
|
|
46
|
-
Returns the front end configuration object extracted from the
|
|
46
|
+
Returns the front end configuration object extracted from the NAT configuration.
|
|
47
47
|
|
|
48
48
|
Returns
|
|
49
49
|
-------
|
|
@@ -55,12 +55,12 @@ class FrontEndBase(typing.Generic[FrontEndConfigT], ABC):
|
|
|
55
55
|
@property
|
|
56
56
|
def full_config(self) -> "Config":
|
|
57
57
|
"""
|
|
58
|
-
Returns the full
|
|
58
|
+
Returns the full NAT configuration object.
|
|
59
59
|
|
|
60
60
|
Returns
|
|
61
61
|
-------
|
|
62
|
-
|
|
63
|
-
The full
|
|
62
|
+
Config
|
|
63
|
+
The full NAT configuration object.
|
|
64
64
|
"""
|
|
65
65
|
|
|
66
66
|
return self._full_config
|
nat/builder/function_base.py
CHANGED
|
@@ -12,10 +12,10 @@
|
|
|
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
|
-
"""Base class for
|
|
15
|
+
"""Base class for NAT functions providing type handling and schema management.
|
|
16
16
|
|
|
17
17
|
This module contains the FunctionBase abstract base class which provides core functionality
|
|
18
|
-
for
|
|
18
|
+
for NAT functions including type handling via generics, schema management for inputs and outputs,
|
|
19
19
|
and type conversion capabilities.
|
|
20
20
|
"""
|
|
21
21
|
|
|
@@ -40,7 +40,7 @@ logger = logging.getLogger(__name__)
|
|
|
40
40
|
|
|
41
41
|
class FunctionBase(typing.Generic[InputT, StreamingOutputT, SingleOutputT], ABC):
|
|
42
42
|
"""
|
|
43
|
-
Abstract base class providing core functionality for
|
|
43
|
+
Abstract base class providing core functionality for NAT functions.
|
|
44
44
|
|
|
45
45
|
This class provides type handling via generics, schema management for inputs and outputs,
|
|
46
46
|
and type conversion capabilities.
|
|
@@ -56,7 +56,7 @@ class FunctionBase(typing.Generic[InputT, StreamingOutputT, SingleOutputT], ABC)
|
|
|
56
56
|
|
|
57
57
|
Notes
|
|
58
58
|
-----
|
|
59
|
-
FunctionBase is the foundation of the
|
|
59
|
+
FunctionBase is the foundation of the NAT function system, providing:
|
|
60
60
|
- Type handling via generics
|
|
61
61
|
- Schema management for inputs and outputs
|
|
62
62
|
- Type conversion capabilities
|
nat/builder/function_info.py
CHANGED
|
@@ -574,7 +574,7 @@ class FunctionInfo:
|
|
|
574
574
|
Returns
|
|
575
575
|
-------
|
|
576
576
|
FunctionInfo
|
|
577
|
-
The created FunctionInfo object which can be used to create a Generic
|
|
577
|
+
The created FunctionInfo object which can be used to create a Generic NAT function.
|
|
578
578
|
|
|
579
579
|
"""
|
|
580
580
|
|
|
@@ -43,7 +43,7 @@ class OpenStep:
|
|
|
43
43
|
|
|
44
44
|
class IntermediateStepManager:
|
|
45
45
|
"""
|
|
46
|
-
Manages updates to the
|
|
46
|
+
Manages updates to the NAT Event Stream for intermediate steps
|
|
47
47
|
"""
|
|
48
48
|
|
|
49
49
|
def __init__(self, context_state: "ContextState"): # noqa: F821
|
|
@@ -53,7 +53,7 @@ class IntermediateStepManager:
|
|
|
53
53
|
|
|
54
54
|
def push_intermediate_step(self, payload: IntermediateStepPayload) -> None:
|
|
55
55
|
"""
|
|
56
|
-
Pushes an intermediate step to the
|
|
56
|
+
Pushes an intermediate step to the NAT Event Stream
|
|
57
57
|
"""
|
|
58
58
|
|
|
59
59
|
if not isinstance(payload, IntermediateStepPayload):
|
|
@@ -129,7 +129,7 @@ class IntermediateStepManager:
|
|
|
129
129
|
# Verify that the stack is now equal to the previous stack
|
|
130
130
|
if (curr_stack != prev_stack):
|
|
131
131
|
logger.warning("Current span ID stack is not equal to the previous stack. "
|
|
132
|
-
"This is likely an error. Report this to the
|
|
132
|
+
"This is likely an error. Report this to the NeMo Agent toolkit team.")
|
|
133
133
|
|
|
134
134
|
logger.debug("Popped end step %s, name %s, type %s, parent %s, stack id %s",
|
|
135
135
|
payload.UUID,
|
|
@@ -168,7 +168,7 @@ class IntermediateStepManager:
|
|
|
168
168
|
on_error: OnError = None,
|
|
169
169
|
on_complete: OnComplete = None) -> Subscription:
|
|
170
170
|
"""
|
|
171
|
-
Subscribes to the
|
|
171
|
+
Subscribes to the NAT Event Stream for intermediate steps
|
|
172
172
|
"""
|
|
173
173
|
|
|
174
174
|
return self._context_state.event_stream.get().subscribe(on_next, on_error, on_complete)
|
|
@@ -30,12 +30,12 @@ class UserInteractionManager:
|
|
|
30
30
|
"""
|
|
31
31
|
UserInteractionManager is responsible for requesting user input
|
|
32
32
|
at runtime. It delegates the actual prompting to a callback function
|
|
33
|
-
stored in
|
|
33
|
+
stored in ContextState.user_input_callback.
|
|
34
34
|
|
|
35
35
|
Type is not imported in __init__ to prevent partial import.
|
|
36
36
|
"""
|
|
37
37
|
|
|
38
|
-
def __init__(self, context_state: "
|
|
38
|
+
def __init__(self, context_state: "ContextState") -> None: # noqa: F821
|
|
39
39
|
self._context_state = context_state
|
|
40
40
|
|
|
41
41
|
@staticmethod
|
|
@@ -54,7 +54,7 @@ class UserInteractionManager:
|
|
|
54
54
|
"""
|
|
55
55
|
Ask the user a question and wait for input. This calls out to
|
|
56
56
|
the callback from user_input_callback, which is typically
|
|
57
|
-
set by
|
|
57
|
+
set by SessionManager.
|
|
58
58
|
|
|
59
59
|
Returns the user's typed-in answer as a string.
|
|
60
60
|
"""
|
nat/builder/workflow_builder.py
CHANGED
|
@@ -183,7 +183,7 @@ class WorkflowBuilder(Builder, AbstractAsyncContextManager):
|
|
|
183
183
|
# Store them in a dict so we can un-register them if needed
|
|
184
184
|
self._logging_handlers[key] = handler
|
|
185
185
|
|
|
186
|
-
# Now attach to
|
|
186
|
+
# Now attach to NAT's root logger
|
|
187
187
|
logging.getLogger().addHandler(handler)
|
|
188
188
|
|
|
189
189
|
# Add the telemetry exporters
|
|
@@ -865,7 +865,7 @@ class WorkflowBuilder(Builder, AbstractAsyncContextManager):
|
|
|
865
865
|
Populate the builder with components and optionally set up the workflow.
|
|
866
866
|
|
|
867
867
|
Args:
|
|
868
|
-
config (
|
|
868
|
+
config (Config): The configuration object containing component definitions.
|
|
869
869
|
skip_workflow (bool): If True, skips the workflow instantiation step. Defaults to False.
|
|
870
870
|
|
|
871
871
|
"""
|
nat/cli/cli_utils/validation.py
CHANGED
|
@@ -26,7 +26,7 @@ def validate_config(config_file: Path) -> Config:
|
|
|
26
26
|
try:
|
|
27
27
|
from nat.runtime.loader import load_config
|
|
28
28
|
|
|
29
|
-
# Load using the
|
|
29
|
+
# Load using the NAT loader functions. This performs validation
|
|
30
30
|
config = load_config(config_file)
|
|
31
31
|
|
|
32
32
|
return config
|
|
@@ -20,7 +20,7 @@ import click
|
|
|
20
20
|
logger = logging.getLogger(__name__)
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
@click.group(name=__name__, invoke_without_command=True, help="Utility to add
|
|
23
|
+
@click.group(name=__name__, invoke_without_command=True, help="Utility to add a NAT remote registry channel.")
|
|
24
24
|
@click.argument("channel_type", type=str)
|
|
25
25
|
def add(channel_type: str) -> None:
|
|
26
26
|
from nat.utils.settings.global_settings import add_channel_interative
|
|
@@ -24,9 +24,7 @@ from nat.cli.commands.configure.channel.update import update
|
|
|
24
24
|
logger = logging.getLogger(__name__)
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
@click.group(name=__name__,
|
|
28
|
-
invoke_without_command=False,
|
|
29
|
-
help="Utility to configure AIQ Toolkit remote registry channels.")
|
|
27
|
+
@click.group(name=__name__, invoke_without_command=False, help="Utility to configure NAT remote registry channels.")
|
|
30
28
|
def channel(**kwargs):
|
|
31
29
|
pass
|
|
32
30
|
|
|
@@ -22,7 +22,7 @@ logger = logging.getLogger(__name__)
|
|
|
22
22
|
|
|
23
23
|
@click.group(name=__name__,
|
|
24
24
|
invoke_without_command=True,
|
|
25
|
-
help="Utility to remove a configured
|
|
25
|
+
help="Utility to remove a configured NAT remote registry channel.")
|
|
26
26
|
@click.argument("channel", type=str)
|
|
27
27
|
def remove(channel: str):
|
|
28
28
|
from nat.utils.settings.global_settings import remove_channel_interactive
|
|
@@ -22,7 +22,7 @@ logger = logging.getLogger(__name__)
|
|
|
22
22
|
|
|
23
23
|
@click.group(name="update",
|
|
24
24
|
invoke_without_command=True,
|
|
25
|
-
help="Utility to update
|
|
25
|
+
help="Utility to update a NAT remote registry channel's settings.")
|
|
26
26
|
@click.argument("channel", type=str)
|
|
27
27
|
def update(channel):
|
|
28
28
|
from nat.utils.settings.global_settings import update_channel_interactive
|
|
@@ -22,10 +22,10 @@ from nat.cli.commands.configure.channel.channel import channel
|
|
|
22
22
|
logger = logging.getLogger(__name__)
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
@click.group(name=__name__, invoke_without_command=False, help="Configure
|
|
25
|
+
@click.group(name=__name__, invoke_without_command=False, help="Configure NAT developer preferences.")
|
|
26
26
|
def configure_command(**kwargs):
|
|
27
27
|
"""
|
|
28
|
-
Publish
|
|
28
|
+
Publish NAT artifacts with the specified configuration
|
|
29
29
|
"""
|
|
30
30
|
pass
|
|
31
31
|
|
nat/cli/commands/evaluate.py
CHANGED
nat/cli/commands/info/info.py
CHANGED
|
@@ -24,12 +24,10 @@ from nat.cli.commands.info.list_mcp import list_mcp
|
|
|
24
24
|
logger = logging.getLogger(__name__)
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
@click.group(name=__name__,
|
|
28
|
-
invoke_without_command=False,
|
|
29
|
-
help="Provide information about the local AIQ Toolkit environment.")
|
|
27
|
+
@click.group(name=__name__, invoke_without_command=False, help="Provide information about the local NAT environment.")
|
|
30
28
|
def info_command(**kwargs):
|
|
31
29
|
"""
|
|
32
|
-
Provide information about the local
|
|
30
|
+
Provide information about the local NAT environment.
|
|
33
31
|
"""
|
|
34
32
|
pass
|
|
35
33
|
|
|
@@ -60,7 +60,7 @@ async def search_artifacts( # pylint: disable=R0917
|
|
|
60
60
|
registry_handler.save_search_results(search_response=search_response, save_path=save_path)
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
@click.group(name=__name__, invoke_without_command=True, help="List the locally registered
|
|
63
|
+
@click.group(name=__name__, invoke_without_command=True, help="List the locally registered NAT components.")
|
|
64
64
|
@click.option(
|
|
65
65
|
"-t",
|
|
66
66
|
"--types",
|
|
@@ -68,7 +68,7 @@ async def search_artifacts( # pylint: disable=R0917
|
|
|
68
68
|
multiple=True,
|
|
69
69
|
type=click.Choice([e.value for e in ComponentEnum], case_sensitive=False),
|
|
70
70
|
required=False,
|
|
71
|
-
help=("Filter the search by
|
|
71
|
+
help=("Filter the search by NAT component type."),
|
|
72
72
|
)
|
|
73
73
|
@click.option(
|
|
74
74
|
"-o",
|
|
@@ -248,11 +248,11 @@ def list_mcp(ctx: click.Context, direct: bool, url: str, tool: str | None, detai
|
|
|
248
248
|
json_output (bool): Whether to output tool metadata in JSON format instead of text
|
|
249
249
|
|
|
250
250
|
Examples:
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
251
|
+
nat info mcp # List tool names only
|
|
252
|
+
nat info mcp --detail # Show all tools with full details
|
|
253
|
+
nat info mcp --tool my_tool # Show details for specific tool
|
|
254
|
+
nat info mcp --json-output # Get JSON format output
|
|
255
|
+
nat info mcp --direct --url http://... # Use direct protocol with custom URL
|
|
256
256
|
"""
|
|
257
257
|
if ctx.invoked_subcommand is not None:
|
|
258
258
|
return
|
|
@@ -288,10 +288,10 @@ def ping(url: str, timeout: int, json_output: bool) -> None:
|
|
|
288
288
|
json_output (bool): Whether to output the result in JSON format
|
|
289
289
|
|
|
290
290
|
Examples:
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
291
|
+
nat info mcp ping # Ping default server
|
|
292
|
+
nat info mcp ping --url http://custom-server:9901/sse # Ping custom server
|
|
293
|
+
nat info mcp ping --timeout 10 # Use 10 second timeout
|
|
294
|
+
nat info mcp ping --json-output # Get JSON format output
|
|
295
295
|
"""
|
|
296
296
|
result = asyncio.run(ping_mcp_server(url, timeout))
|
|
297
297
|
|
|
@@ -47,7 +47,7 @@ async def publish_artifact(registry_handler_config: RegistryHandlerBaseConfig, p
|
|
|
47
47
|
|
|
48
48
|
@click.group(name=__name__,
|
|
49
49
|
invoke_without_command=True,
|
|
50
|
-
help=("Publish local
|
|
50
|
+
help=("Publish local NAT artifacts to a remote "
|
|
51
51
|
"registry from package repository."))
|
|
52
52
|
@click.option(
|
|
53
53
|
"--config_file",
|
|
@@ -61,12 +61,12 @@ async def publish_artifact(registry_handler_config: RegistryHandlerBaseConfig, p
|
|
|
61
61
|
"--channel",
|
|
62
62
|
type=str,
|
|
63
63
|
required=True,
|
|
64
|
-
help=("The remote registry channel to use when publishing the
|
|
64
|
+
help=("The remote registry channel to use when publishing the NAT artifact."),
|
|
65
65
|
)
|
|
66
66
|
@click.argument("package_root", type=str)
|
|
67
67
|
def publish(channel: str, config_file: str, package_root: str) -> None:
|
|
68
68
|
"""
|
|
69
|
-
Publish
|
|
69
|
+
Publish NAT artifacts with the specified configuration
|
|
70
70
|
"""
|
|
71
71
|
from nat.settings.global_settings import GlobalSettings
|
|
72
72
|
|