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
nat/profiler/profile_runner.py
CHANGED
|
@@ -49,7 +49,7 @@ class InferenceOptimizationHolder(BaseModel):
|
|
|
49
49
|
|
|
50
50
|
class ProfilerRunner:
|
|
51
51
|
"""
|
|
52
|
-
A utility to run a series of prompts through
|
|
52
|
+
A utility to run a series of prompts through a NAT workflow for profiling:
|
|
53
53
|
|
|
54
54
|
- can load prompts from a file
|
|
55
55
|
- or generate them via an LLM
|
|
@@ -42,10 +42,10 @@ class LocalRegistryHandler(AbstractRegistryHandler):
|
|
|
42
42
|
|
|
43
43
|
@asynccontextmanager
|
|
44
44
|
async def publish(self, artifact: Artifact) -> AsyncGenerator[PublishResponse]:
|
|
45
|
-
"""Publishes
|
|
45
|
+
"""Publishes a NAT artifact to a local registry.
|
|
46
46
|
|
|
47
47
|
Args:
|
|
48
|
-
artifact (
|
|
48
|
+
artifact (Artifact): An artifact that contain NAT plugin wheel and it's corrosponding discovery
|
|
49
49
|
metadata.
|
|
50
50
|
|
|
51
51
|
Yields:
|
|
@@ -62,10 +62,10 @@ class LocalRegistryHandler(AbstractRegistryHandler):
|
|
|
62
62
|
|
|
63
63
|
@asynccontextmanager
|
|
64
64
|
async def pull(self, packages: PullRequestPackages) -> AsyncGenerator[PullResponse]:
|
|
65
|
-
"""Download and install
|
|
65
|
+
"""Download and install NAT artifacts from a local registry.
|
|
66
66
|
|
|
67
67
|
Args:
|
|
68
|
-
packages (PullRequestPackages): Parameters used to pull the
|
|
68
|
+
packages (PullRequestPackages): Parameters used to pull the NAT artifact.
|
|
69
69
|
|
|
70
70
|
Yields:
|
|
71
71
|
Iterator[AsyncGenerator[PullResponse]]: A response message that includes a the pulled packages and a
|
|
@@ -83,7 +83,7 @@ class LocalRegistryHandler(AbstractRegistryHandler):
|
|
|
83
83
|
|
|
84
84
|
@asynccontextmanager
|
|
85
85
|
async def search(self, query: SearchQuery) -> AsyncGenerator[SearchResponse]:
|
|
86
|
-
"""Searches the local
|
|
86
|
+
"""Searches the local nat registry for relevant NAT components.
|
|
87
87
|
|
|
88
88
|
Args:
|
|
89
89
|
query (SearchQuery): Parameters of the search to be performed.
|
|
@@ -22,7 +22,7 @@ logger = logging.getLogger(__name__)
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
class LocalRegistryHandlerConfig(RegistryHandlerBaseConfig, name="local"):
|
|
25
|
-
"""Interact with the local
|
|
25
|
+
"""Interact with the local NAT environment to search and uninstall NAT components."""
|
|
26
26
|
|
|
27
27
|
pass
|
|
28
28
|
|
|
@@ -89,13 +89,13 @@ def resolve_extras_to_packages(package_name: str, extras: list[str]) -> set[str]
|
|
|
89
89
|
"""Resolve package extras to their actual package dependencies.
|
|
90
90
|
|
|
91
91
|
Args:
|
|
92
|
-
package_name (str): The base package name (e.g., '
|
|
92
|
+
package_name (str): The base package name (e.g., 'nvidia-nat')
|
|
93
93
|
extras (list[str]): List of extra names (e.g., ['langchain', 'telemetry'])
|
|
94
94
|
|
|
95
95
|
Returns:
|
|
96
96
|
set[str]: Set of additional package names that the extras resolve to
|
|
97
|
-
(e.g., {'
|
|
98
|
-
'
|
|
97
|
+
(e.g., {'nvidia-nat-langchain', 'nvidia-nat-opentelemetry', 'nvidia-nat-phoenix',
|
|
98
|
+
'nvidia-nat-weave', 'nvidia-nat-ragaai'})
|
|
99
99
|
"""
|
|
100
100
|
resolved_packages = set()
|
|
101
101
|
|
|
@@ -149,8 +149,8 @@ def extract_dependencies_with_extras_resolved(pyproject_path: str) -> set[str]:
|
|
|
149
149
|
set[str]: Set of all dependency names including those resolved from extras
|
|
150
150
|
|
|
151
151
|
Example:
|
|
152
|
-
For a dependency like "
|
|
153
|
-
{'
|
|
152
|
+
For a dependency like "nat[langchain,telemetry]~=1.2", this will return:
|
|
153
|
+
{'nvidia-nat', 'nvidia-nat-langchain', 'nvidia-nat-opentelemetry', 'nvidia-nat-phoenix', ...}
|
|
154
154
|
|
|
155
155
|
Raises:
|
|
156
156
|
FileNotFoundError: If the pyproject.toml file doesn't exist
|
|
@@ -287,7 +287,7 @@ def get_transitive_dependencies(distribution_names: list[str]) -> dict[str, set[
|
|
|
287
287
|
This function recursively resolves all dependencies for the given distribution names,
|
|
288
288
|
returning a mapping of each package to its complete set of transitive dependencies.
|
|
289
289
|
This is useful when publishing plugins to remote registries that contain with nested dependencies,
|
|
290
|
-
ensuring that all dependencies are included in the
|
|
290
|
+
ensuring that all dependencies are included in the Artifact's metadata.
|
|
291
291
|
|
|
292
292
|
Args:
|
|
293
293
|
distribution_names (list[str]): List of Python distribution names (package names) to analyze.
|
|
@@ -408,7 +408,7 @@ def get_all_transitive_dependencies(distribution_names: list[str]) -> set[str]:
|
|
|
408
408
|
|
|
409
409
|
Returns a flattened set of all unique dependencies across all the provided distribution names.
|
|
410
410
|
This is useful when publishing plugins to remote registries that contain with nested dependencies,
|
|
411
|
-
ensuring that all dependencies are included in the
|
|
411
|
+
ensuring that all dependencies are included in the Artifact's metadata.
|
|
412
412
|
|
|
413
413
|
Args:
|
|
414
414
|
distribution_names: List of Python distribution names (package names) to analyze
|
|
@@ -449,7 +449,7 @@ def build_wheel(package_root: str) -> WheelData:
|
|
|
449
449
|
|
|
450
450
|
toml_project: dict = data.get("project", {})
|
|
451
451
|
toml_project_name = toml_project.get("name", None)
|
|
452
|
-
toml_packages = set(i for i in data.get("project", {}).get("entry-points", {}).get("
|
|
452
|
+
toml_packages = set(i for i in data.get("project", {}).get("entry-points", {}).get("nat.plugins", {}))
|
|
453
453
|
|
|
454
454
|
# Extract dependencies using the robust requirement parser with extras resolution
|
|
455
455
|
try:
|
|
@@ -488,13 +488,13 @@ def build_wheel(package_root: str) -> WheelData:
|
|
|
488
488
|
|
|
489
489
|
os.chdir(working_dir)
|
|
490
490
|
|
|
491
|
-
whl_version = Wheel(whl_path).version
|
|
491
|
+
whl_version = Wheel(whl_path).version or "unknown"
|
|
492
492
|
|
|
493
493
|
return WheelData(package_root=package_root,
|
|
494
494
|
package_name=toml_project_name,
|
|
495
495
|
toml_project=toml_project,
|
|
496
496
|
toml_dependencies=toml_dependencies,
|
|
497
|
-
|
|
497
|
+
toml_nat_packages=toml_packages,
|
|
498
498
|
union_dependencies=union_dependencies,
|
|
499
499
|
whl_path=whl_path,
|
|
500
500
|
whl_base64=whl_base64,
|
|
@@ -502,13 +502,13 @@ def build_wheel(package_root: str) -> WheelData:
|
|
|
502
502
|
|
|
503
503
|
|
|
504
504
|
def build_package_metadata(wheel_data: WheelData | None) -> dict[ComponentEnum, list[dict | DiscoveryMetadata]]:
|
|
505
|
-
"""Loads discovery metadata for all registered
|
|
505
|
+
"""Loads discovery metadata for all registered NAT components included in this Python package.
|
|
506
506
|
|
|
507
507
|
Args:
|
|
508
508
|
wheel_data (WheelData): Data model containing a built python wheel and its corresponding metadata.
|
|
509
509
|
|
|
510
510
|
Returns:
|
|
511
|
-
dict[
|
|
511
|
+
dict[ComponentEnum, list[typing.Union[dict, DiscoveryMetadata]]]: List containing each components discovery
|
|
512
512
|
metadata.
|
|
513
513
|
"""
|
|
514
514
|
|
|
@@ -520,11 +520,11 @@ def build_package_metadata(wheel_data: WheelData | None) -> dict[ComponentEnum,
|
|
|
520
520
|
|
|
521
521
|
registry = GlobalTypeRegistry.get()
|
|
522
522
|
|
|
523
|
-
|
|
523
|
+
nat_plugins = discover_entrypoints(PluginTypes.ALL)
|
|
524
524
|
|
|
525
525
|
if (wheel_data is not None):
|
|
526
526
|
registry.register_package(package_name=wheel_data.package_name, package_version=wheel_data.whl_version)
|
|
527
|
-
for entry_point in
|
|
527
|
+
for entry_point in nat_plugins:
|
|
528
528
|
package_name = entry_point.dist.name
|
|
529
529
|
if (package_name == wheel_data.package_name):
|
|
530
530
|
continue
|
|
@@ -532,7 +532,7 @@ def build_package_metadata(wheel_data: WheelData | None) -> dict[ComponentEnum,
|
|
|
532
532
|
registry.register_package(package_name=package_name)
|
|
533
533
|
|
|
534
534
|
else:
|
|
535
|
-
for entry_point in
|
|
535
|
+
for entry_point in nat_plugins:
|
|
536
536
|
registry.register_package(package_name=entry_point.dist.name)
|
|
537
537
|
|
|
538
538
|
discovery_metadata = {}
|
|
@@ -549,13 +549,13 @@ def build_package_metadata(wheel_data: WheelData | None) -> dict[ComponentEnum,
|
|
|
549
549
|
|
|
550
550
|
|
|
551
551
|
def build_artifact(package_root: str) -> Artifact:
|
|
552
|
-
"""Builds a complete
|
|
552
|
+
"""Builds a complete NeMo Agent toolkit Artifact that can be published for discovery and reuse.
|
|
553
553
|
|
|
554
554
|
Args:
|
|
555
555
|
package_root (str): Path to root of python package
|
|
556
556
|
|
|
557
557
|
Returns:
|
|
558
|
-
|
|
558
|
+
Artifact: A publishable Artifact containing package wheel and discovery metadata.
|
|
559
559
|
"""
|
|
560
560
|
|
|
561
561
|
from nat.registry_handlers.schemas.publish import BuiltArtifact
|
|
@@ -60,10 +60,10 @@ class PypiRegistryHandler(AbstractRegistryHandler):
|
|
|
60
60
|
|
|
61
61
|
@asynccontextmanager
|
|
62
62
|
async def publish(self, artifact: Artifact) -> AsyncGenerator[PublishResponse]:
|
|
63
|
-
"""Publishes
|
|
63
|
+
"""Publishes a NAT artifact to a PyPI remote registry.
|
|
64
64
|
|
|
65
65
|
Args:
|
|
66
|
-
artifact (
|
|
66
|
+
artifact (Artifact): An artifact that contain NAT plugin wheel and it's corrosponding discovery
|
|
67
67
|
metadata.
|
|
68
68
|
|
|
69
69
|
Yields:
|
|
@@ -101,10 +101,10 @@ class PypiRegistryHandler(AbstractRegistryHandler):
|
|
|
101
101
|
|
|
102
102
|
@asynccontextmanager
|
|
103
103
|
async def pull(self, packages: PullRequestPackages) -> AsyncGenerator[PullResponse]:
|
|
104
|
-
"""Download and install
|
|
104
|
+
"""Download and install NAT artifacts from a remote PyPI remote registry.
|
|
105
105
|
|
|
106
106
|
Args:
|
|
107
|
-
packages (PullRequestPackages): Parameters used to pull the
|
|
107
|
+
packages (PullRequestPackages): Parameters used to pull the NAT artifact.
|
|
108
108
|
|
|
109
109
|
Yields:
|
|
110
110
|
Iterator[AsyncGenerator[PullResponse, None]]: A response message that includes a the pulled packages and a
|
|
@@ -160,7 +160,7 @@ class PypiRegistryHandler(AbstractRegistryHandler):
|
|
|
160
160
|
|
|
161
161
|
@asynccontextmanager
|
|
162
162
|
async def search(self, query: SearchQuery) -> AsyncGenerator[SearchResponse]:
|
|
163
|
-
"""Searches a remote PyPI registry for relevant
|
|
163
|
+
"""Searches a remote PyPI registry for relevant NAT components.
|
|
164
164
|
|
|
165
165
|
Args:
|
|
166
166
|
query (SearchQuery): Parameters of the search to be performed.
|
|
@@ -25,9 +25,9 @@ class PypiRegistryHandlerConfig(RegistryHandlerBaseConfig, name="pypi"):
|
|
|
25
25
|
endpoint: str = Field(description="A string representing the remote endpoint.")
|
|
26
26
|
token: str | None = Field(default=None,
|
|
27
27
|
description="The authentication token to use when interacting with the registry.")
|
|
28
|
-
publish_route: str = Field(description="The route to the
|
|
29
|
-
pull_route: str = Field(description="The route to the
|
|
30
|
-
search_route: str = Field(default="simple", description="The route to the
|
|
28
|
+
publish_route: str = Field(description="The route to the NAT publish service.")
|
|
29
|
+
pull_route: str = Field(description="The route to the NAT pull service.")
|
|
30
|
+
search_route: str = Field(default="simple", description="The route to the NAT search service.")
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
@register_registry_handler(config_type=PypiRegistryHandlerConfig)
|
|
@@ -33,11 +33,11 @@ from nat.registry_handlers.schemas.search import VisualizeFields
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
class AbstractRegistryHandler(ABC):
|
|
36
|
-
"""Base class outlining the interfaces for remote
|
|
36
|
+
"""Base class outlining the interfaces for remote NAT registry interactions."""
|
|
37
37
|
|
|
38
38
|
def __init__(self):
|
|
39
39
|
self._discovery_metadata: dict[ComponentEnum, list[dict | DiscoveryMetadata]] = {}
|
|
40
|
-
self.
|
|
40
|
+
self._nat_artifact: Artifact | None = None
|
|
41
41
|
self._whl_bytes: bytes
|
|
42
42
|
self._whl_path: str
|
|
43
43
|
self._whl_base64: str
|
|
@@ -45,10 +45,10 @@ class AbstractRegistryHandler(ABC):
|
|
|
45
45
|
@abstractmethod
|
|
46
46
|
@asynccontextmanager
|
|
47
47
|
async def publish(self, artifact: Artifact) -> AsyncGenerator[PublishResponse]:
|
|
48
|
-
"""Publishes
|
|
48
|
+
"""Publishes a NAT artifact to a remote registry.
|
|
49
49
|
|
|
50
50
|
Args:
|
|
51
|
-
artifact (
|
|
51
|
+
artifact (Artifact): An artifact that contain NAT plugin wheel and it's corrosponding discovery
|
|
52
52
|
metadata.
|
|
53
53
|
|
|
54
54
|
Yields:
|
|
@@ -61,10 +61,10 @@ class AbstractRegistryHandler(ABC):
|
|
|
61
61
|
@abstractmethod
|
|
62
62
|
@asynccontextmanager
|
|
63
63
|
async def pull(self, packages: PullRequestPackages) -> AsyncGenerator[PullResponse]:
|
|
64
|
-
"""Download and install
|
|
64
|
+
"""Download and install NAT artifacts from a remote registry.
|
|
65
65
|
|
|
66
66
|
Args:
|
|
67
|
-
packages (PullRequestPackages): Parameters used to pull the
|
|
67
|
+
packages (PullRequestPackages): Parameters used to pull the NAT artifact.
|
|
68
68
|
|
|
69
69
|
Yields:
|
|
70
70
|
Iterator[AsyncGenerator[PullResponse]]: A response message that includes a the pulled packages and a
|
|
@@ -76,7 +76,7 @@ class AbstractRegistryHandler(ABC):
|
|
|
76
76
|
@abstractmethod
|
|
77
77
|
@asynccontextmanager
|
|
78
78
|
async def search(self, query: SearchQuery) -> AsyncGenerator[SearchResponse]:
|
|
79
|
-
"""Searches the local
|
|
79
|
+
"""Searches the local nat registry for relevant NAT components.
|
|
80
80
|
|
|
81
81
|
Args:
|
|
82
82
|
query (SearchQuery): Parameters of the search to be performed.
|
|
@@ -118,7 +118,7 @@ class AbstractRegistryHandler(ABC):
|
|
|
118
118
|
from rich.table import Table
|
|
119
119
|
from rich.text import Text
|
|
120
120
|
|
|
121
|
-
table = Table(title="
|
|
121
|
+
table = Table(title="NAT Search Results", padding=(0, 1), show_lines=True)
|
|
122
122
|
for column in VisualizeFields:
|
|
123
123
|
table.add_column(column.value)
|
|
124
124
|
|
|
@@ -27,10 +27,10 @@ class RestRegistryHandlerConfig(RegistryHandlerBaseConfig, name="rest"):
|
|
|
27
27
|
endpoint: str = Field(description="A string representing the remote endpoint.")
|
|
28
28
|
token: str | None = Field(default=None,
|
|
29
29
|
description="The authentication token to use when interacting with the registry.")
|
|
30
|
-
publish_route: str = Field(default="", description="The route to the
|
|
31
|
-
pull_route: str = Field(default="", description="The route to the
|
|
32
|
-
search_route: str = Field(default="", description="The route to the
|
|
33
|
-
remove_route: str = Field(default="", description="The route to the
|
|
30
|
+
publish_route: str = Field(default="", description="The route to the NAT publish service.")
|
|
31
|
+
pull_route: str = Field(default="", description="The route to the NAT pull service.")
|
|
32
|
+
search_route: str = Field(default="", description="The route to the NAT search service")
|
|
33
|
+
remove_route: str = Field(default="", description="The route to the NAT remove service")
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
@register_registry_handler(config_type=RestRegistryHandlerConfig)
|
|
@@ -62,10 +62,10 @@ class RestRegistryHandler(AbstractRegistryHandler):
|
|
|
62
62
|
|
|
63
63
|
@asynccontextmanager
|
|
64
64
|
async def publish(self, artifact: Artifact) -> AsyncGenerator[PublishResponse]:
|
|
65
|
-
"""Publishes
|
|
65
|
+
"""Publishes a NAT artifact to a remote REST registry.
|
|
66
66
|
|
|
67
67
|
Args:
|
|
68
|
-
artifact (
|
|
68
|
+
artifact (Artifact): An artifact that contain NAT plugin wheel and it's corrosponding discovery
|
|
69
69
|
metadata.
|
|
70
70
|
|
|
71
71
|
Yields:
|
|
@@ -98,17 +98,17 @@ class RestRegistryHandler(AbstractRegistryHandler):
|
|
|
98
98
|
|
|
99
99
|
@asynccontextmanager
|
|
100
100
|
async def pull(self, packages: PullRequestPackages) -> AsyncGenerator[PullResponse]:
|
|
101
|
-
"""Download and install
|
|
101
|
+
"""Download and install NAT artifacts from a remote REST registry.
|
|
102
102
|
|
|
103
103
|
Args:
|
|
104
|
-
packages (PullRequestPackages): Parameters used to pull the
|
|
104
|
+
packages (PullRequestPackages): Parameters used to pull the NAT artifact.
|
|
105
105
|
|
|
106
106
|
Yields:
|
|
107
107
|
Iterator[AsyncGenerator[PullResponse]]: A response message that includes a the pulled packages and a
|
|
108
108
|
completion status message.
|
|
109
109
|
"""
|
|
110
110
|
|
|
111
|
-
tmp_dir = "
|
|
111
|
+
tmp_dir = "./.tmp/nat-pull"
|
|
112
112
|
|
|
113
113
|
try:
|
|
114
114
|
async with httpx.AsyncClient(headers=self._headers, timeout=self._timeout) as client:
|
|
@@ -165,7 +165,7 @@ class RestRegistryHandler(AbstractRegistryHandler):
|
|
|
165
165
|
|
|
166
166
|
@asynccontextmanager
|
|
167
167
|
async def search(self, query: SearchQuery) -> AsyncGenerator[SearchResponse]:
|
|
168
|
-
"""Searches a remote REST registry for relevant
|
|
168
|
+
"""Searches a remote REST registry for relevant NAT components.
|
|
169
169
|
|
|
170
170
|
Args:
|
|
171
171
|
query (SearchQuery): Parameters of the search to be performed.
|
|
@@ -28,8 +28,8 @@ class WheelData(BaseModel):
|
|
|
28
28
|
package_name (str): The name of the python package.
|
|
29
29
|
toml_project (dict): A dictionary containing data about the python project.
|
|
30
30
|
toml_dependencies (set): The list of dependencies provided in the pyproject.toml file.
|
|
31
|
-
|
|
32
|
-
union_dependencies (set): The union of toml_dependencies and
|
|
31
|
+
toml_nat_packages (set): The NAT plugins listed in the pyproject.toml.
|
|
32
|
+
union_dependencies (set): The union of toml_dependencies and toml_nat_packages.
|
|
33
33
|
whl_path (str): The path to the package wheel file.
|
|
34
34
|
whl_base64 (str): Base64 encoded string of the wheel file.
|
|
35
35
|
whl_version (str): The version representing the wheel file.
|
|
@@ -39,7 +39,7 @@ class WheelData(BaseModel):
|
|
|
39
39
|
package_name: str
|
|
40
40
|
toml_project: dict
|
|
41
41
|
toml_dependencies: set
|
|
42
|
-
|
|
42
|
+
toml_nat_packages: set
|
|
43
43
|
union_dependencies: set
|
|
44
44
|
whl_path: str
|
|
45
45
|
whl_base64: str
|
|
@@ -25,10 +25,10 @@ logger = logging.getLogger(__name__)
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
class BuiltArtifact(BaseModel):
|
|
28
|
-
"""
|
|
28
|
+
"""A NAT artifact including base64 encoded string of wheel package and corrosponding discovery metadata.
|
|
29
29
|
|
|
30
30
|
Args:
|
|
31
|
-
whl (str): A base64 encoded string of
|
|
31
|
+
whl (str): A base64 encoded string of a NAT package wheel (.whl).
|
|
32
32
|
|
|
33
33
|
metadata (dict[ComponentEnum, list[DiscoveryMetadata]]): Provides rich discover metadata for developers to
|
|
34
34
|
quickly find useful components.
|
|
@@ -39,10 +39,10 @@ class BuiltArtifact(BaseModel):
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
class Artifact(BaseModel):
|
|
42
|
-
"""
|
|
42
|
+
"""A NAT artifact including base64 encoded string of wheel package and corrosponding discovery metadata.
|
|
43
43
|
|
|
44
44
|
Args:
|
|
45
|
-
artifact (BuiltArtifact):
|
|
45
|
+
artifact (BuiltArtifact): A NAT artifact including base64 encoded string of wheel package and
|
|
46
46
|
corrosponding discovery metadata.
|
|
47
47
|
|
|
48
48
|
whl_path (str): A local path to the built wheel package.
|
|
@@ -27,7 +27,7 @@ class PulledPackage(BaseModel):
|
|
|
27
27
|
"""Represents a data model of a pulled package containing the package wheel and its name.
|
|
28
28
|
|
|
29
29
|
Args:
|
|
30
|
-
whl (str): Base64 encoded string of the
|
|
30
|
+
whl (str): Base64 encoded string of the NAT python package wheel (.whl).
|
|
31
31
|
whl_name (str): A string representing the wheel filename.
|
|
32
32
|
"""
|
|
33
33
|
|
|
@@ -37,7 +37,7 @@ class PulledPackage(BaseModel):
|
|
|
37
37
|
|
|
38
38
|
class PullResponse(BaseModel):
|
|
39
39
|
"""
|
|
40
|
-
Represents a data model of the expected respones from a
|
|
40
|
+
Represents a data model of the expected respones from a NAT pull request, including detailed status
|
|
41
41
|
information.
|
|
42
42
|
|
|
43
43
|
Args:
|
|
@@ -72,11 +72,11 @@ class PullRequestPackage(BaseModel):
|
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
class PullRequestPackages(BaseModel):
|
|
75
|
-
"""Represents a list of all packages th download and install in the local
|
|
75
|
+
"""Represents a list of all packages th download and install in the local NAT environment.
|
|
76
76
|
|
|
77
77
|
Args:
|
|
78
78
|
packages (list[typing.Union[PackageNameVersion, PullPackageWhl]]): A list of packages that can be
|
|
79
|
-
downloaded and installed in the local
|
|
79
|
+
downloaded and installed in the local NAT environment.
|
|
80
80
|
"""
|
|
81
81
|
|
|
82
82
|
packages: list[PackageNameVersion | PullPackageWhl]
|
|
@@ -42,12 +42,12 @@ class VisualizeFields(str, Enum):
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
class SearchQuery(BaseModel):
|
|
45
|
-
"""Represents the search criteria that will be used to discover useful
|
|
45
|
+
"""Represents the search criteria that will be used to discover useful NAT components.
|
|
46
46
|
|
|
47
47
|
Args:
|
|
48
|
-
query (str): A query string used to find useful
|
|
48
|
+
query (str): A query string used to find useful NAT components.
|
|
49
49
|
fields (list[SearchFields]): The list of fields used when applying the query string.
|
|
50
|
-
component_types (list[
|
|
50
|
+
component_types (list[ComponentEnum]): NAT components types to filter search results.
|
|
51
51
|
top_k (int): Specifies the number of search results to provide.
|
|
52
52
|
"""
|
|
53
53
|
|
|
@@ -61,10 +61,10 @@ class SearchResponseItem(BaseModel):
|
|
|
61
61
|
"""Represents an individual item in the search response, including elements of it's discovery metadata.
|
|
62
62
|
|
|
63
63
|
Args:
|
|
64
|
-
package (str): The name of the
|
|
65
|
-
version (str): The version of the
|
|
66
|
-
component_type (
|
|
67
|
-
description (str): A description of this
|
|
64
|
+
package (str): The name of the NAT package that includes the component.
|
|
65
|
+
version (str): The version of the NAT package that includes the component.
|
|
66
|
+
component_type (ComponentEnum): Type of NAT component this item represents.
|
|
67
|
+
description (str): A description of this NAT component.
|
|
68
68
|
developer_notes (str): Additional details that would help a developer use this component.
|
|
69
69
|
"""
|
|
70
70
|
|
nat/runtime/loader.py
CHANGED
|
@@ -58,7 +58,7 @@ class PluginTypes(IntFlag):
|
|
|
58
58
|
# Convenience flag for groups of plugin types
|
|
59
59
|
CONFIG_OBJECT = COMPONENT | FRONT_END | EVALUATOR | AUTHENTICATION
|
|
60
60
|
"""
|
|
61
|
-
Any plugin that can be specified in the
|
|
61
|
+
Any plugin that can be specified in the NAT configuration file.
|
|
62
62
|
"""
|
|
63
63
|
ALL = COMPONENT | FRONT_END | EVALUATOR | REGISTRY_HANDLER | AUTHENTICATION
|
|
64
64
|
"""
|
|
@@ -68,8 +68,8 @@ class PluginTypes(IntFlag):
|
|
|
68
68
|
|
|
69
69
|
def load_config(config_file: StrPath) -> Config:
|
|
70
70
|
"""
|
|
71
|
-
This is the primary entry point for loading
|
|
72
|
-
loaded and then validates the configuration file against the
|
|
71
|
+
This is the primary entry point for loading a NAT configuration file. It ensures that all plugins are
|
|
72
|
+
loaded and then validates the configuration file against the Config schema.
|
|
73
73
|
|
|
74
74
|
Parameters
|
|
75
75
|
----------
|
|
@@ -78,8 +78,8 @@ def load_config(config_file: StrPath) -> Config:
|
|
|
78
78
|
|
|
79
79
|
Returns
|
|
80
80
|
-------
|
|
81
|
-
|
|
82
|
-
The validated
|
|
81
|
+
Config
|
|
82
|
+
The validated Config object
|
|
83
83
|
"""
|
|
84
84
|
|
|
85
85
|
# Ensure all of the plugins are loaded
|
|
@@ -87,17 +87,17 @@ def load_config(config_file: StrPath) -> Config:
|
|
|
87
87
|
|
|
88
88
|
config_yaml = yaml_load(config_file)
|
|
89
89
|
|
|
90
|
-
# Validate configuration adheres to
|
|
91
|
-
|
|
90
|
+
# Validate configuration adheres to NAT schemas
|
|
91
|
+
validated_nat_config = validate_schema(config_yaml, Config)
|
|
92
92
|
|
|
93
|
-
return
|
|
93
|
+
return validated_nat_config
|
|
94
94
|
|
|
95
95
|
|
|
96
96
|
@asynccontextmanager
|
|
97
97
|
async def load_workflow(config_file: StrPath, max_concurrency: int = -1):
|
|
98
98
|
"""
|
|
99
|
-
Load the
|
|
100
|
-
|
|
99
|
+
Load the NAT configuration file and create an Runner object. This is the primary entry point for running
|
|
100
|
+
NAT workflows.
|
|
101
101
|
|
|
102
102
|
Parameters
|
|
103
103
|
----------
|
|
@@ -128,16 +128,17 @@ def discover_entrypoints(plugin_type: PluginTypes):
|
|
|
128
128
|
plugin_groups = []
|
|
129
129
|
|
|
130
130
|
# Add the specified plugin type to the list of groups to load
|
|
131
|
+
# The aiq entrypoints are intentionally left in the list to maintain backwards compatibility.
|
|
131
132
|
if (plugin_type & PluginTypes.COMPONENT):
|
|
132
|
-
plugin_groups.extend(["nat.plugins", "nat.components"])
|
|
133
|
+
plugin_groups.extend(["aiq.plugins", "aiq.components", "nat.plugins", "nat.components"])
|
|
133
134
|
if (plugin_type & PluginTypes.FRONT_END):
|
|
134
|
-
plugin_groups.
|
|
135
|
+
plugin_groups.extend(["aiq.front_ends", "nat.front_ends"])
|
|
135
136
|
if (plugin_type & PluginTypes.REGISTRY_HANDLER):
|
|
136
|
-
plugin_groups.
|
|
137
|
+
plugin_groups.extend(["aiq.registry_handlers", "nat.registry_handlers"])
|
|
137
138
|
if (plugin_type & PluginTypes.EVALUATOR):
|
|
138
|
-
plugin_groups.
|
|
139
|
+
plugin_groups.extend(["aiq.evaluators", "nat.evaluators"])
|
|
139
140
|
if (plugin_type & PluginTypes.AUTHENTICATION):
|
|
140
|
-
plugin_groups.
|
|
141
|
+
plugin_groups.extend(["aiq.authentication_providers", "nat.authentication_providers"])
|
|
141
142
|
|
|
142
143
|
# Get the entry points for the specified groups
|
|
143
144
|
nat_plugins = reduce(lambda x, y: list(x) + list(y), [entry_points.select(group=y) for y in plugin_groups])
|
|
@@ -148,12 +149,12 @@ def discover_entrypoints(plugin_type: PluginTypes):
|
|
|
148
149
|
@lru_cache
|
|
149
150
|
def get_all_entrypoints_distro_mapping() -> dict[str, str]:
|
|
150
151
|
"""
|
|
151
|
-
Get the mapping of all
|
|
152
|
+
Get the mapping of all NAT entry points to their distribution names.
|
|
152
153
|
"""
|
|
153
154
|
|
|
154
155
|
mapping = {}
|
|
155
|
-
|
|
156
|
-
for ep in
|
|
156
|
+
nat_entrypoints = discover_entrypoints(PluginTypes.ALL)
|
|
157
|
+
for ep in nat_entrypoints:
|
|
157
158
|
ep_module_parts = ep.module.split(".")
|
|
158
159
|
current_parts = []
|
|
159
160
|
for part in ep_module_parts:
|
|
@@ -171,14 +172,14 @@ def discover_and_register_plugins(plugin_type: PluginTypes):
|
|
|
171
172
|
"""
|
|
172
173
|
|
|
173
174
|
# Get the entry points for the specified groups
|
|
174
|
-
|
|
175
|
+
nat_plugins = discover_entrypoints(plugin_type)
|
|
175
176
|
|
|
176
177
|
count = 0
|
|
177
178
|
|
|
178
179
|
# Pause registration hooks for performance. This is useful when loading a large number of plugins.
|
|
179
180
|
with GlobalTypeRegistry.get().pause_registration_changed_hooks():
|
|
180
181
|
|
|
181
|
-
for entry_point in
|
|
182
|
+
for entry_point in nat_plugins:
|
|
182
183
|
try:
|
|
183
184
|
logger.debug("Loading module '%s' from entry point '%s'...", entry_point.module, entry_point.name)
|
|
184
185
|
|
nat/runtime/runner.py
CHANGED
|
@@ -50,7 +50,7 @@ class Runner:
|
|
|
50
50
|
context_state: ContextState,
|
|
51
51
|
exporter_manager: ExporterManager):
|
|
52
52
|
"""
|
|
53
|
-
The
|
|
53
|
+
The Runner class is used to run a workflow. It handles converting input and output data types and running the
|
|
54
54
|
workflow with the specified concurrency.
|
|
55
55
|
|
|
56
56
|
Parameters
|
|
@@ -59,7 +59,7 @@ class Runner:
|
|
|
59
59
|
The input message to the workflow
|
|
60
60
|
entry_fn : Function
|
|
61
61
|
The entry function to the workflow
|
|
62
|
-
context_state :
|
|
62
|
+
context_state : ContextState
|
|
63
63
|
The context state to use
|
|
64
64
|
exporter_manager : ExporterManager
|
|
65
65
|
The exporter manager to use
|
nat/runtime/session.py
CHANGED
|
@@ -44,7 +44,7 @@ class SessionManager:
|
|
|
44
44
|
|
|
45
45
|
def __init__(self, workflow: Workflow, max_concurrency: int = 8):
|
|
46
46
|
"""
|
|
47
|
-
The
|
|
47
|
+
The SessionManager class is used to run and manage a user workflow session. It runs and manages the context,
|
|
48
48
|
and configuration of a workflow with the specified concurrency.
|
|
49
49
|
|
|
50
50
|
Parameters
|
nat/settings/global_settings.py
CHANGED
|
@@ -152,7 +152,7 @@ class Settings(HashableBaseModel):
|
|
|
152
152
|
@staticmethod
|
|
153
153
|
def from_file():
|
|
154
154
|
|
|
155
|
-
configuration_directory = os.getenv("
|
|
155
|
+
configuration_directory = os.getenv("NAT_CONFIG_DIR", user_config_dir(appname="nat"))
|
|
156
156
|
|
|
157
157
|
if not os.path.exists(configuration_directory):
|
|
158
158
|
os.makedirs(configuration_directory, exist_ok=True)
|
|
@@ -181,7 +181,7 @@ class Settings(HashableBaseModel):
|
|
|
181
181
|
if (remove):
|
|
182
182
|
if os.path.exists(self.configuration_directory):
|
|
183
183
|
os.rmdir(self.configuration_directory)
|
|
184
|
-
self._configuration_directory = os.getenv("
|
|
184
|
+
self._configuration_directory = os.getenv("NAT_CONFIG_DIR", user_config_dir(appname="nat"))
|
|
185
185
|
|
|
186
186
|
def _save_settings(self) -> None:
|
|
187
187
|
|
nat/tool/chat_completion.py
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
"""
|
|
16
|
-
Simple Completion Function for
|
|
16
|
+
Simple Completion Function for NAT
|
|
17
17
|
|
|
18
18
|
This module provides a simple completion function that can handle
|
|
19
19
|
natural language queries and perform basic text completion tasks.
|
|
@@ -35,7 +35,7 @@ The Code Execution Sandbox provides:
|
|
|
35
35
|
Navigate to the local sandbox directory and start the server:
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
|
-
cd src/
|
|
38
|
+
cd src/nat/tool/code_execution/local_sandbox
|
|
39
39
|
./start_local_sandbox.sh
|
|
40
40
|
```
|
|
41
41
|
|
|
@@ -62,7 +62,7 @@ export OUTPUT_DATA_PATH=/path/to/output
|
|
|
62
62
|
Run the comprehensive test suite to verify everything is working:
|
|
63
63
|
|
|
64
64
|
```bash
|
|
65
|
-
cd src/
|
|
65
|
+
cd src/nat/tool/code_execution
|
|
66
66
|
pytest test_code_execution_sandbox.py
|
|
67
67
|
```
|
|
68
68
|
|