nvidia-nat 1.3.0a20250923__py3-none-any.whl → 1.3.0a20250925__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/agent.py +5 -4
- nat/agent/react_agent/register.py +12 -1
- nat/agent/reasoning_agent/reasoning_agent.py +2 -2
- nat/agent/rewoo_agent/register.py +12 -1
- nat/agent/tool_calling_agent/register.py +28 -8
- nat/builder/builder.py +33 -24
- nat/builder/component_utils.py +1 -1
- nat/builder/eval_builder.py +14 -9
- nat/builder/framework_enum.py +1 -0
- nat/builder/function.py +108 -52
- nat/builder/workflow_builder.py +89 -79
- nat/cli/commands/info/info.py +16 -6
- nat/cli/commands/mcp/__init__.py +14 -0
- nat/cli/commands/mcp/mcp.py +786 -0
- nat/cli/entrypoint.py +2 -1
- nat/control_flow/router_agent/register.py +1 -1
- nat/control_flow/sequential_executor.py +6 -7
- nat/eval/evaluate.py +2 -1
- nat/eval/trajectory_evaluator/register.py +1 -1
- nat/experimental/decorators/experimental_warning_decorator.py +26 -5
- nat/experimental/test_time_compute/functions/plan_select_execute_function.py +2 -2
- nat/experimental/test_time_compute/functions/ttc_tool_orchestration_function.py +1 -1
- nat/experimental/test_time_compute/functions/ttc_tool_wrapper_function.py +1 -1
- nat/experimental/test_time_compute/models/strategy_base.py +2 -2
- nat/front_ends/console/console_front_end_plugin.py +4 -3
- nat/front_ends/fastapi/fastapi_front_end_plugin_worker.py +3 -3
- nat/front_ends/mcp/mcp_front_end_plugin_worker.py +4 -4
- nat/front_ends/simple_base/simple_front_end_plugin_base.py +3 -1
- nat/llm/litellm_llm.py +69 -0
- nat/llm/register.py +4 -0
- nat/profiler/decorators/framework_wrapper.py +52 -3
- nat/profiler/decorators/function_tracking.py +33 -1
- nat/profiler/parameter_optimization/prompt_optimizer.py +2 -2
- nat/runtime/loader.py +1 -1
- nat/utils/type_converter.py +4 -3
- nat/utils/type_utils.py +1 -1
- {nvidia_nat-1.3.0a20250923.dist-info → nvidia_nat-1.3.0a20250925.dist-info}/METADATA +6 -3
- {nvidia_nat-1.3.0a20250923.dist-info → nvidia_nat-1.3.0a20250925.dist-info}/RECORD +43 -41
- nat/cli/commands/info/list_mcp.py +0 -461
- {nvidia_nat-1.3.0a20250923.dist-info → nvidia_nat-1.3.0a20250925.dist-info}/WHEEL +0 -0
- {nvidia_nat-1.3.0a20250923.dist-info → nvidia_nat-1.3.0a20250925.dist-info}/entry_points.txt +0 -0
- {nvidia_nat-1.3.0a20250923.dist-info → nvidia_nat-1.3.0a20250925.dist-info}/licenses/LICENSE-3rd-party.txt +0 -0
- {nvidia_nat-1.3.0a20250923.dist-info → nvidia_nat-1.3.0a20250925.dist-info}/licenses/LICENSE.md +0 -0
- {nvidia_nat-1.3.0a20250923.dist-info → nvidia_nat-1.3.0a20250925.dist-info}/top_level.txt +0 -0
nat/builder/function.py
CHANGED
|
@@ -357,7 +357,7 @@ class FunctionGroup:
|
|
|
357
357
|
*,
|
|
358
358
|
config: FunctionGroupBaseConfig,
|
|
359
359
|
instance_name: str | None = None,
|
|
360
|
-
filter_fn: Callable[[Sequence[str]], Sequence[str]] | None = None):
|
|
360
|
+
filter_fn: Callable[[Sequence[str]], Awaitable[Sequence[str]]] | None = None):
|
|
361
361
|
"""
|
|
362
362
|
Creates a new function group.
|
|
363
363
|
|
|
@@ -367,7 +367,7 @@ class FunctionGroup:
|
|
|
367
367
|
The configuration for the function group.
|
|
368
368
|
instance_name : str | None, optional
|
|
369
369
|
The name of the function group. If not provided, the type of the function group will be used.
|
|
370
|
-
filter_fn : Callable[[Sequence[str]], Sequence[str]] | None, optional
|
|
370
|
+
filter_fn : Callable[[Sequence[str]], Awaitable[Sequence[str]]] | None, optional
|
|
371
371
|
A callback function to additionally filter the functions in the function group dynamically when
|
|
372
372
|
the functions are accessed via any accessor method.
|
|
373
373
|
"""
|
|
@@ -375,7 +375,7 @@ class FunctionGroup:
|
|
|
375
375
|
self._instance_name = instance_name or config.type
|
|
376
376
|
self._functions: dict[str, Function] = dict()
|
|
377
377
|
self._filter_fn = filter_fn
|
|
378
|
-
self._per_function_filter_fn: dict[str, Callable[[str], bool]] = dict()
|
|
378
|
+
self._per_function_filter_fn: dict[str, Callable[[str], Awaitable[bool]]] = dict()
|
|
379
379
|
|
|
380
380
|
def add_function(self,
|
|
381
381
|
name: str,
|
|
@@ -384,7 +384,7 @@ class FunctionGroup:
|
|
|
384
384
|
input_schema: type[BaseModel] | None = None,
|
|
385
385
|
description: str | None = None,
|
|
386
386
|
converters: list[Callable] | None = None,
|
|
387
|
-
filter_fn: Callable[[str], bool] | None = None):
|
|
387
|
+
filter_fn: Callable[[str], Awaitable[bool]] | None = None):
|
|
388
388
|
"""
|
|
389
389
|
Adds a function to the function group.
|
|
390
390
|
|
|
@@ -400,7 +400,7 @@ class FunctionGroup:
|
|
|
400
400
|
The description of the function.
|
|
401
401
|
converters : list[Callable] | None, optional
|
|
402
402
|
The converters to use for the function.
|
|
403
|
-
filter_fn : Callable[[str], bool] | None, optional
|
|
403
|
+
filter_fn : Callable[[str], Awaitable[bool]] | None, optional
|
|
404
404
|
A callback to determine if the function should be included in the function group. The
|
|
405
405
|
callback will be called with the function name. The callback is invoked dynamically when
|
|
406
406
|
the functions are accessed via any accessor method such as `get_accessible_functions`,
|
|
@@ -441,12 +441,14 @@ class FunctionGroup:
|
|
|
441
441
|
def _get_fn_name(self, name: str) -> str:
|
|
442
442
|
return f"{self._instance_name}.{name}"
|
|
443
443
|
|
|
444
|
-
def _fn_should_be_included(self, name: str) -> bool:
|
|
445
|
-
|
|
444
|
+
async def _fn_should_be_included(self, name: str) -> bool:
|
|
445
|
+
if name not in self._per_function_filter_fn:
|
|
446
|
+
return True
|
|
447
|
+
return await self._per_function_filter_fn[name](name)
|
|
446
448
|
|
|
447
|
-
def _get_all_but_excluded_functions(
|
|
449
|
+
async def _get_all_but_excluded_functions(
|
|
448
450
|
self,
|
|
449
|
-
filter_fn: Callable[[Sequence[str]], Sequence[str]] | None = None,
|
|
451
|
+
filter_fn: Callable[[Sequence[str]], Awaitable[Sequence[str]]] | None = None,
|
|
450
452
|
) -> dict[str, Function]:
|
|
451
453
|
"""
|
|
452
454
|
Returns a dictionary of all functions in the function group except the excluded functions.
|
|
@@ -454,22 +456,35 @@ class FunctionGroup:
|
|
|
454
456
|
missing = set(self._config.exclude) - set(self._functions.keys())
|
|
455
457
|
if missing:
|
|
456
458
|
raise ValueError(f"Unknown excluded functions: {sorted(missing)}")
|
|
457
|
-
|
|
459
|
+
|
|
460
|
+
if filter_fn is None:
|
|
461
|
+
if self._filter_fn is None:
|
|
462
|
+
|
|
463
|
+
async def identity_filter(x: Sequence[str]) -> Sequence[str]:
|
|
464
|
+
return x
|
|
465
|
+
|
|
466
|
+
filter_fn = identity_filter
|
|
467
|
+
else:
|
|
468
|
+
filter_fn = self._filter_fn
|
|
469
|
+
|
|
458
470
|
excluded = set(self._config.exclude)
|
|
459
|
-
included = set(filter_fn(list(self._functions.keys())))
|
|
471
|
+
included = set(await filter_fn(list(self._functions.keys())))
|
|
460
472
|
|
|
461
|
-
|
|
473
|
+
result = {}
|
|
474
|
+
for name in self._functions:
|
|
462
475
|
if name in excluded:
|
|
463
|
-
|
|
464
|
-
if not self._fn_should_be_included(name):
|
|
465
|
-
|
|
466
|
-
|
|
476
|
+
continue
|
|
477
|
+
if not await self._fn_should_be_included(name):
|
|
478
|
+
continue
|
|
479
|
+
if name not in included:
|
|
480
|
+
continue
|
|
481
|
+
result[self._get_fn_name(name)] = self._functions[name]
|
|
467
482
|
|
|
468
|
-
return
|
|
483
|
+
return result
|
|
469
484
|
|
|
470
|
-
def get_accessible_functions(
|
|
485
|
+
async def get_accessible_functions(
|
|
471
486
|
self,
|
|
472
|
-
filter_fn: Callable[[Sequence[str]], Sequence[str]] | None = None,
|
|
487
|
+
filter_fn: Callable[[Sequence[str]], Awaitable[Sequence[str]]] | None = None,
|
|
473
488
|
) -> dict[str, Function]:
|
|
474
489
|
"""
|
|
475
490
|
Returns a dictionary of all accessible functions in the function group.
|
|
@@ -484,7 +499,7 @@ class FunctionGroup:
|
|
|
484
499
|
|
|
485
500
|
Parameters
|
|
486
501
|
----------
|
|
487
|
-
filter_fn : Callable[[Sequence[str]], Sequence[str]] | None, optional
|
|
502
|
+
filter_fn : Callable[[Sequence[str]], Awaitable[Sequence[str]]] | None, optional
|
|
488
503
|
A callback function to additionally filter the functions in the function group dynamically. If not provided
|
|
489
504
|
then fall back to the function group's filter function. If no filter function is set for the function group
|
|
490
505
|
all functions will be returned.
|
|
@@ -500,14 +515,14 @@ class FunctionGroup:
|
|
|
500
515
|
When the function group is configured to include functions that are not found in the group.
|
|
501
516
|
"""
|
|
502
517
|
if self._config.include:
|
|
503
|
-
return self.get_included_functions(filter_fn=filter_fn)
|
|
518
|
+
return await self.get_included_functions(filter_fn=filter_fn)
|
|
504
519
|
if self._config.exclude:
|
|
505
|
-
return self._get_all_but_excluded_functions(filter_fn=filter_fn)
|
|
506
|
-
return self.get_all_functions(filter_fn=filter_fn)
|
|
520
|
+
return await self._get_all_but_excluded_functions(filter_fn=filter_fn)
|
|
521
|
+
return await self.get_all_functions(filter_fn=filter_fn)
|
|
507
522
|
|
|
508
|
-
def get_excluded_functions(
|
|
523
|
+
async def get_excluded_functions(
|
|
509
524
|
self,
|
|
510
|
-
filter_fn: Callable[[Sequence[str]], Sequence[str]] | None = None,
|
|
525
|
+
filter_fn: Callable[[Sequence[str]], Awaitable[Sequence[str]]] | None = None,
|
|
511
526
|
) -> dict[str, Function]:
|
|
512
527
|
"""
|
|
513
528
|
Returns a dictionary of all functions in the function group which are configured to be excluded or filtered
|
|
@@ -515,7 +530,7 @@ class FunctionGroup:
|
|
|
515
530
|
|
|
516
531
|
Parameters
|
|
517
532
|
----------
|
|
518
|
-
filter_fn : Callable[[Sequence[str]], Sequence[str]] | None, optional
|
|
533
|
+
filter_fn : Callable[[Sequence[str]], Awaitable[Sequence[str]]] | None, optional
|
|
519
534
|
A callback function to additionally filter the functions in the function group dynamically. If not provided
|
|
520
535
|
then fall back to the function group's filter function. If no filter function is set for the function group
|
|
521
536
|
then no functions will be added to the returned dictionary.
|
|
@@ -533,22 +548,38 @@ class FunctionGroup:
|
|
|
533
548
|
missing = set(self._config.exclude) - set(self._functions.keys())
|
|
534
549
|
if missing:
|
|
535
550
|
raise ValueError(f"Unknown excluded functions: {sorted(missing)}")
|
|
536
|
-
|
|
551
|
+
|
|
552
|
+
if filter_fn is None:
|
|
553
|
+
if self._filter_fn is None:
|
|
554
|
+
|
|
555
|
+
async def identity_filter(x: Sequence[str]) -> Sequence[str]:
|
|
556
|
+
return x
|
|
557
|
+
|
|
558
|
+
filter_fn = identity_filter
|
|
559
|
+
else:
|
|
560
|
+
filter_fn = self._filter_fn
|
|
561
|
+
|
|
537
562
|
excluded = set(self._config.exclude)
|
|
538
|
-
included = set(filter_fn(list(self._functions.keys())))
|
|
563
|
+
included = set(await filter_fn(list(self._functions.keys())))
|
|
539
564
|
|
|
540
|
-
|
|
565
|
+
result = {}
|
|
566
|
+
for name in self._functions:
|
|
567
|
+
is_excluded = False
|
|
541
568
|
if name in excluded:
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
569
|
+
is_excluded = True
|
|
570
|
+
elif not await self._fn_should_be_included(name):
|
|
571
|
+
is_excluded = True
|
|
572
|
+
elif name not in included:
|
|
573
|
+
is_excluded = True
|
|
546
574
|
|
|
547
|
-
|
|
575
|
+
if is_excluded:
|
|
576
|
+
result[self._get_fn_name(name)] = self._functions[name]
|
|
548
577
|
|
|
549
|
-
|
|
578
|
+
return result
|
|
579
|
+
|
|
580
|
+
async def get_included_functions(
|
|
550
581
|
self,
|
|
551
|
-
filter_fn: Callable[[Sequence[str]], Sequence[str]] | None = None,
|
|
582
|
+
filter_fn: Callable[[Sequence[str]], Awaitable[Sequence[str]]] | None = None,
|
|
552
583
|
) -> dict[str, Function]:
|
|
553
584
|
"""
|
|
554
585
|
Returns a dictionary of all functions in the function group which are:
|
|
@@ -558,7 +589,7 @@ class FunctionGroup:
|
|
|
558
589
|
|
|
559
590
|
Parameters
|
|
560
591
|
----------
|
|
561
|
-
filter_fn : Callable[[Sequence[str]], Sequence[str]] | None, optional
|
|
592
|
+
filter_fn : Callable[[Sequence[str]], Awaitable[Sequence[str]]] | None, optional
|
|
562
593
|
A callback function to additionally filter the functions in the function group dynamically. If not provided
|
|
563
594
|
then fall back to the function group's filter function. If no filter function is set for the function group
|
|
564
595
|
all functions will be returned.
|
|
@@ -576,14 +607,27 @@ class FunctionGroup:
|
|
|
576
607
|
missing = set(self._config.include) - set(self._functions.keys())
|
|
577
608
|
if missing:
|
|
578
609
|
raise ValueError(f"Unknown included functions: {sorted(missing)}")
|
|
579
|
-
filter_fn = filter_fn or self._filter_fn or (lambda x: x)
|
|
580
|
-
included = set(filter_fn(list(self._config.include)))
|
|
581
|
-
included = {name for name in included if self._fn_should_be_included(name)}
|
|
582
|
-
return {self._get_fn_name(name): self._functions[name] for name in included}
|
|
583
610
|
|
|
584
|
-
|
|
611
|
+
if filter_fn is None:
|
|
612
|
+
if self._filter_fn is None:
|
|
613
|
+
|
|
614
|
+
async def identity_filter(x: Sequence[str]) -> Sequence[str]:
|
|
615
|
+
return x
|
|
616
|
+
|
|
617
|
+
filter_fn = identity_filter
|
|
618
|
+
else:
|
|
619
|
+
filter_fn = self._filter_fn
|
|
620
|
+
|
|
621
|
+
included = set(await filter_fn(list(self._config.include)))
|
|
622
|
+
result = {}
|
|
623
|
+
for name in included:
|
|
624
|
+
if await self._fn_should_be_included(name):
|
|
625
|
+
result[self._get_fn_name(name)] = self._functions[name]
|
|
626
|
+
return result
|
|
627
|
+
|
|
628
|
+
async def get_all_functions(
|
|
585
629
|
self,
|
|
586
|
-
filter_fn: Callable[[Sequence[str]], Sequence[str]] | None = None,
|
|
630
|
+
filter_fn: Callable[[Sequence[str]], Awaitable[Sequence[str]]] | None = None,
|
|
587
631
|
) -> dict[str, Function]:
|
|
588
632
|
"""
|
|
589
633
|
Returns a dictionary of all functions in the function group, regardless if they are included or excluded.
|
|
@@ -592,7 +636,7 @@ class FunctionGroup:
|
|
|
592
636
|
|
|
593
637
|
Parameters
|
|
594
638
|
----------
|
|
595
|
-
filter_fn : Callable[[Sequence[str]], Sequence[str]] | None, optional
|
|
639
|
+
filter_fn : Callable[[Sequence[str]], Awaitable[Sequence[str]]] | None, optional
|
|
596
640
|
A callback function to additionally filter the functions in the function group dynamically. If not provided
|
|
597
641
|
then fall back to the function group's filter function. If no filter function is set for the function group
|
|
598
642
|
all functions will be returned.
|
|
@@ -602,23 +646,35 @@ class FunctionGroup:
|
|
|
602
646
|
dict[str, Function]
|
|
603
647
|
A dictionary of all functions in the function group.
|
|
604
648
|
"""
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
649
|
+
if filter_fn is None:
|
|
650
|
+
if self._filter_fn is None:
|
|
651
|
+
|
|
652
|
+
async def identity_filter(x: Sequence[str]) -> Sequence[str]:
|
|
653
|
+
return x
|
|
654
|
+
|
|
655
|
+
filter_fn = identity_filter
|
|
656
|
+
else:
|
|
657
|
+
filter_fn = self._filter_fn
|
|
658
|
+
|
|
659
|
+
included = set(await filter_fn(list(self._functions.keys())))
|
|
660
|
+
result = {}
|
|
661
|
+
for name in included:
|
|
662
|
+
if await self._fn_should_be_included(name):
|
|
663
|
+
result[self._get_fn_name(name)] = self._functions[name]
|
|
664
|
+
return result
|
|
609
665
|
|
|
610
|
-
def set_filter_fn(self, filter_fn: Callable[[Sequence[str]], Sequence[str]]):
|
|
666
|
+
def set_filter_fn(self, filter_fn: Callable[[Sequence[str]], Awaitable[Sequence[str]]]):
|
|
611
667
|
"""
|
|
612
668
|
Sets the filter function for the function group.
|
|
613
669
|
|
|
614
670
|
Parameters
|
|
615
671
|
----------
|
|
616
|
-
filter_fn : Callable[[Sequence[str]], Sequence[str]]
|
|
672
|
+
filter_fn : Callable[[Sequence[str]], Awaitable[Sequence[str]]]
|
|
617
673
|
The filter function to set for the function group.
|
|
618
674
|
"""
|
|
619
675
|
self._filter_fn = filter_fn
|
|
620
676
|
|
|
621
|
-
def set_per_function_filter_fn(self, name: str, filter_fn: Callable[[str], bool]):
|
|
677
|
+
def set_per_function_filter_fn(self, name: str, filter_fn: Callable[[str], Awaitable[bool]]):
|
|
622
678
|
"""
|
|
623
679
|
Sets the a per-function filter function for the a function within the function group.
|
|
624
680
|
|
|
@@ -626,7 +682,7 @@ class FunctionGroup:
|
|
|
626
682
|
----------
|
|
627
683
|
name : str
|
|
628
684
|
The name of the function.
|
|
629
|
-
filter_fn : Callable[[str], bool]
|
|
685
|
+
filter_fn : Callable[[str], Awaitable[bool]]
|
|
630
686
|
The per-function filter function to set for the function group.
|
|
631
687
|
|
|
632
688
|
Raises
|