nvidia-nat 1.3.0rc5__py3-none-any.whl → 1.3.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/builder/context.py CHANGED
@@ -19,6 +19,7 @@ from collections.abc import Awaitable
19
19
  from collections.abc import Callable
20
20
  from contextlib import contextmanager
21
21
  from contextvars import ContextVar
22
+ from functools import cached_property
22
23
 
23
24
  from nat.builder.intermediate_step_manager import IntermediateStepManager
24
25
  from nat.builder.user_interaction_manager import UserInteractionManager
@@ -167,7 +168,7 @@ class Context:
167
168
  """
168
169
  return UserInteractionManager(self._context_state)
169
170
 
170
- @property
171
+ @cached_property
171
172
  def intermediate_step_manager(self) -> IntermediateStepManager:
172
173
  """
173
174
  Retrieves the intermediate step manager instance from the current context state.
@@ -91,7 +91,10 @@ class IntermediateStepManager:
91
91
  open_step = self._outstanding_start_steps.pop(payload.UUID, None)
92
92
 
93
93
  if (open_step is None):
94
- logger.warning("Step id %s not found in outstanding start steps", payload.UUID)
94
+ logger.warning(
95
+ "Step id %s not found in outstanding start steps. "
96
+ "This may occur if the step was started in a different context or already completed.",
97
+ payload.UUID)
95
98
  return
96
99
 
97
100
  parent_step_id = open_step.step_parent_id
@@ -147,7 +150,8 @@ class IntermediateStepManager:
147
150
  if (open_step is None):
148
151
  logger.warning(
149
152
  "Created a chunk for step %s, but no matching start step was found. "
150
- "Chunks must be created with the same ID as the start step.",
153
+ "Chunks must be created with the same ID as the start step. "
154
+ "This may occur if the step was started in a different context.",
151
155
  payload.UUID)
152
156
  return
153
157
 
@@ -116,11 +116,14 @@ class RAGEvaluator:
116
116
  """Convert NaN or None to 0.0 for safe arithmetic/serialization."""
117
117
  return 0.0 if v is None or (isinstance(v, float) and math.isnan(v)) else v
118
118
 
119
- # Convert from list of dicts to dict of lists, coercing NaN/None to 0.0
119
+ # Keep original scores (preserving NaN/None) for output
120
+ original_scores_dict = {metric: [score.get(metric) for score in scores] for metric in scores[0]}
121
+
122
+ # Convert from list of dicts to dict of lists, coercing NaN/None to 0.0 for average calculation
120
123
  scores_dict = {metric: [_nan_to_zero(score.get(metric)) for score in scores] for metric in scores[0]}
121
124
  first_metric_name = list(scores_dict.keys())[0] if scores_dict else None
122
125
 
123
- # Compute the average of each metric, guarding against empty lists
126
+ # Compute the average of each metric using cleaned scores (NaN/None -> 0.0)
124
127
  average_scores = {
125
128
  metric: (sum(values) / len(values) if values else 0.0)
126
129
  for metric, values in scores_dict.items()
@@ -137,11 +140,11 @@ class RAGEvaluator:
137
140
  else:
138
141
  ids = df["user_input"].tolist() # Use "user_input" as ID fallback
139
142
 
140
- # Construct EvalOutputItem list
143
+ # Construct EvalOutputItem list using original scores (preserving NaN/None)
141
144
  eval_output_items = [
142
145
  EvalOutputItem(
143
146
  id=ids[i],
144
- score=_nan_to_zero(getattr(row, first_metric_name, 0.0) if first_metric_name else 0.0),
147
+ score=original_scores_dict[first_metric_name][i] if first_metric_name else None,
145
148
  reasoning={
146
149
  key:
147
150
  getattr(row, key, None) # Use getattr to safely access attributes
@@ -121,6 +121,17 @@ def optimize_parameters(
121
121
  with (out_dir / "trials_dataframe_params.csv").open("w") as fh:
122
122
  # Export full trials DataFrame (values, params, timings, etc.).
123
123
  df = study.trials_dataframe()
124
+
125
+ # Rename values_X columns to actual metric names
126
+ metric_names = list(metric_cfg.keys())
127
+ rename_mapping = {}
128
+ for i, metric_name in enumerate(metric_names):
129
+ old_col = f"values_{i}"
130
+ if old_col in df.columns:
131
+ rename_mapping[old_col] = f"values_{metric_name}"
132
+ if rename_mapping:
133
+ df = df.rename(columns=rename_mapping)
134
+
124
135
  # Normalise rep_scores column naming for convenience.
125
136
  if "user_attrs_rep_scores" in df.columns and "rep_scores" not in df.columns:
126
137
  df = df.rename(columns={"user_attrs_rep_scores": "rep_scores"})
@@ -46,9 +46,13 @@ class ParetoVisualizer:
46
46
 
47
47
  fig, ax = plt.subplots(figsize=figsize)
48
48
 
49
- # Extract metric values
50
- x_vals = trials_df[f"values_{0}"].values
51
- y_vals = trials_df[f"values_{1}"].values
49
+ # Extract metric values - support both old (values_0) and new (values_metricname) formats
50
+ x_col = f"values_{self.metric_names[0]}" \
51
+ if f"values_{self.metric_names[0]}" in trials_df.columns else f"values_{0}"
52
+ y_col = f"values_{self.metric_names[1]}"\
53
+ if f"values_{self.metric_names[1]}" in trials_df.columns else f"values_{1}"
54
+ x_vals = trials_df[x_col].values
55
+ y_vals = trials_df[y_col].values
52
56
 
53
57
  # Plot all trials
54
58
  ax.scatter(x_vals,
@@ -62,8 +66,8 @@ class ParetoVisualizer:
62
66
 
63
67
  # Plot Pareto optimal trials if provided
64
68
  if pareto_trials_df is not None and not pareto_trials_df.empty:
65
- pareto_x = pareto_trials_df[f"values_{0}"].values
66
- pareto_y = pareto_trials_df[f"values_{1}"].values
69
+ pareto_x = pareto_trials_df[x_col].values
70
+ pareto_y = pareto_trials_df[y_col].values
67
71
 
68
72
  ax.scatter(pareto_x,
69
73
  pareto_y,
@@ -98,8 +102,8 @@ class ParetoVisualizer:
98
102
  ax.grid(True, alpha=0.3)
99
103
 
100
104
  # Add direction annotations
101
- x_annotation = (f"Better {self.metric_names[0]} "
102
- if self.directions[0] == "minimize" else f" Better {self.metric_names[0]}")
105
+ x_annotation = (f"Better {self.metric_names[0]} "
106
+ if self.directions[0] == "minimize" else f" Better {self.metric_names[0]}")
103
107
  ax.annotate(x_annotation,
104
108
  xy=(0.02, 0.98),
105
109
  xycoords='axes fraction',
@@ -109,8 +113,8 @@ class ParetoVisualizer:
109
113
  style='italic',
110
114
  bbox=dict(boxstyle="round,pad=0.3", facecolor="wheat", alpha=0.7))
111
115
 
112
- y_annotation = (f"Better {self.metric_names[1]} "
113
- if self.directions[1] == "minimize" else f"Better {self.metric_names[1]} ")
116
+ y_annotation = (f"Better {self.metric_names[1]} "
117
+ if self.directions[1] == "minimize" else f"Better {self.metric_names[1]} ")
114
118
  ax.annotate(y_annotation,
115
119
  xy=(0.02, 0.02),
116
120
  xycoords='axes fraction',
@@ -145,7 +149,10 @@ class ParetoVisualizer:
145
149
  # Normalize values for better visualization
146
150
  all_values = []
147
151
  for i in range(n_metrics):
148
- all_values.append(trials_df[f"values_{i}"].values)
152
+ # Support both old (values_0) and new (values_metricname) formats
153
+ col_name = f"values_{self.metric_names[i]}"\
154
+ if f"values_{self.metric_names[i]}" in trials_df.columns else f"values_{i}"
155
+ all_values.append(trials_df[col_name].values)
149
156
 
150
157
  # Normalize each metric to [0, 1] for parallel coordinates
151
158
  normalized_values = []
@@ -221,23 +228,31 @@ class ParetoVisualizer:
221
228
 
222
229
  if i == j:
223
230
  # Diagonal: histograms
224
- values = trials_df[f"values_{i}"].values
231
+ # Support both old (values_0) and new (values_metricname) formats
232
+ col_name = f"values_{self.metric_names[i]}"\
233
+ if f"values_{self.metric_names[i]}" in trials_df.columns else f"values_{i}"
234
+ values = trials_df[col_name].values
225
235
  ax.hist(values, bins=20, alpha=0.7, color='lightblue', edgecolor='navy')
226
236
  if pareto_trials_df is not None and not pareto_trials_df.empty:
227
- pareto_values = pareto_trials_df[f"values_{i}"].values
237
+ pareto_values = pareto_trials_df[col_name].values
228
238
  ax.hist(pareto_values, bins=20, alpha=0.8, color='red', edgecolor='darkred')
229
239
  ax.set_xlabel(f"{self.metric_names[i]}")
230
240
  ax.set_ylabel("Frequency")
231
241
  else:
232
242
  # Off-diagonal: scatter plots
233
- x_vals = trials_df[f"values_{j}"].values
234
- y_vals = trials_df[f"values_{i}"].values
243
+ # Support both old (values_0) and new (values_metricname) formats
244
+ x_col = f"values_{self.metric_names[j]}"\
245
+ if f"values_{self.metric_names[j]}" in trials_df.columns else f"values_{j}"
246
+ y_col = f"values_{self.metric_names[i]}"\
247
+ if f"values_{self.metric_names[i]}" in trials_df.columns else f"values_{i}"
248
+ x_vals = trials_df[x_col].values
249
+ y_vals = trials_df[y_col].values
235
250
 
236
251
  ax.scatter(x_vals, y_vals, alpha=0.6, s=30, c='lightblue', edgecolors='navy', linewidths=0.5)
237
252
 
238
253
  if pareto_trials_df is not None and not pareto_trials_df.empty:
239
- pareto_x = pareto_trials_df[f"values_{j}"].values
240
- pareto_y = pareto_trials_df[f"values_{i}"].values
254
+ pareto_x = pareto_trials_df[x_col].values
255
+ pareto_y = pareto_trials_df[y_col].values
241
256
  ax.scatter(pareto_x,
242
257
  pareto_y,
243
258
  alpha=0.9,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nvidia-nat
3
- Version: 1.3.0rc5
3
+ Version: 1.3.0rc6
4
4
  Summary: NVIDIA NeMo Agent toolkit
5
5
  Author: NVIDIA Corporation
6
6
  Maintainer: NVIDIA Corporation
@@ -84,10 +84,11 @@ Requires-Dist: nvidia-nat-s3; extra == "s3"
84
84
  Provides-Extra: semantic-kernel
85
85
  Requires-Dist: nvidia-nat-semantic-kernel; extra == "semantic-kernel"
86
86
  Provides-Extra: telemetry
87
+ Requires-Dist: nvidia-nat-data-flywheel; extra == "telemetry"
87
88
  Requires-Dist: nvidia-nat-opentelemetry; extra == "telemetry"
88
89
  Requires-Dist: nvidia-nat-phoenix; extra == "telemetry"
89
- Requires-Dist: nvidia-nat-weave; extra == "telemetry"
90
90
  Requires-Dist: nvidia-nat-ragaai; extra == "telemetry"
91
+ Requires-Dist: nvidia-nat-weave; extra == "telemetry"
91
92
  Provides-Extra: weave
92
93
  Requires-Dist: nvidia-nat-weave; extra == "weave"
93
94
  Provides-Extra: zep-cloud
@@ -42,7 +42,7 @@ nat/authentication/oauth2/register.py,sha256=7rXhf-ilgSS_bUJsd9pOOCotL1FM8dKUt3k
42
42
  nat/builder/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
43
  nat/builder/builder.py,sha256=okI3Y101hwF63AwazzxiahQx-W9eFZ_SNdFXzDuoftU,11608
44
44
  nat/builder/component_utils.py,sha256=gxDhm4NCLI1GU0XL9gFe_gife0oJLwgk_YuABJneFfs,13838
45
- nat/builder/context.py,sha256=6NQmHfJS0gY4eLU7Xg84olmrgUdtVJcS3gmxc-OADiw,13093
45
+ nat/builder/context.py,sha256=YmgYHzXggPQCOIBj1Mirr7xKM7NvtVr3XrSfn979fDM,13138
46
46
  nat/builder/embedder.py,sha256=NPkOEcxt_-wc53QRijCQQDLretRUYHRYaKoYmarmrBk,965
47
47
  nat/builder/eval_builder.py,sha256=I-ScvupmorClYoVBIs_PhSsB7Xf9e2nGWe0rCZp3txo,6857
48
48
  nat/builder/evaluator.py,sha256=xWHMND2vcAUkdFP7FU3jnVki1rUHeTa0-9saFh2hWKs,1162
@@ -51,7 +51,7 @@ nat/builder/front_end.py,sha256=FCJ87NSshVVuTg8zZrq3YAr_u0RaYVZVcibnqlRFy-M,2173
51
51
  nat/builder/function.py,sha256=eZZWLwhphgQTnPvbga8sGleX7HCP46usZPIegE7zFzs,27725
52
52
  nat/builder/function_base.py,sha256=0Eg8RtjWhEU3Yme0CVxcRutobA0Qo8-YHZLI6L2qAgM,13116
53
53
  nat/builder/function_info.py,sha256=7Rmrn-gOFrT2TIJklJwA_O-ycx_oimwZ0-qMYpbuZrU,25161
54
- nat/builder/intermediate_step_manager.py,sha256=iOuMLWTaES0J0XzaLxhTUqFvuoCAChJu3V69T43K0k0,7599
54
+ nat/builder/intermediate_step_manager.py,sha256=wTfCV47IKpYO7NvoHSD4BGwOiuZ8Db9ktzs14T38gBE,7834
55
55
  nat/builder/llm.py,sha256=DW-2q64A06VChsXNEL5PfBjH3DcsnTKVoCEWDuP7MF4,951
56
56
  nat/builder/retriever.py,sha256=ZyEqc7pFK31t_yr6Jaxa34c-tRas2edKqJZCNiVh9-0,970
57
57
  nat/builder/user_interaction_manager.py,sha256=-Z2qbQes7a2cuXgT7KEbWeuok0HcCnRdw9WB8Ghyl9k,3081
@@ -170,7 +170,7 @@ nat/eval/evaluator/__init__.py,sha256=GUJrgGtpvyMUCjUBvR3faAdv-tZzbU9W-izgx9aMEQ
170
170
  nat/eval/evaluator/base_evaluator.py,sha256=5WaVGhCGzkynCJyQdxRv7CtqLoUpr6B4O8tilP_gb3g,3232
171
171
  nat/eval/evaluator/evaluator_model.py,sha256=riGCcDW8YwC3Kd1yoVmbMdJE1Yf2kVmO8uhsGsKKJA4,1878
172
172
  nat/eval/rag_evaluator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
173
- nat/eval/rag_evaluator/evaluate.py,sha256=iQ_fUg1PAuIB2gH6Y7Gz9PeztsdhEswUjyUMa5ZXEx4,8399
173
+ nat/eval/rag_evaluator/evaluate.py,sha256=IfCpfCKBTYhReRkPPbOqyr-9H6gsPGaeFWBIcGDUynw,8639
174
174
  nat/eval/rag_evaluator/register.py,sha256=AzT5uICDU5dEo7scvStmOWC7ac-S0Tx4UY87idGtXIs,5835
175
175
  nat/eval/runners/__init__.py,sha256=GUJrgGtpvyMUCjUBvR3faAdv-tZzbU9W-izgx9aMEQg,680
176
176
  nat/eval/runners/config.py,sha256=bRPai_th02OJrFepbbY6w-t7A18TBXozQUnnnH9iWIU,1403
@@ -367,9 +367,9 @@ nat/profiler/inference_optimization/experimental/prefix_span_analysis.py,sha256=
367
367
  nat/profiler/parameter_optimization/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
368
368
  nat/profiler/parameter_optimization/optimizable_utils.py,sha256=93Pl8A14Zq_f3XsxSH-yFnEJ6B7W5hp7doPnPoLlRB4,3714
369
369
  nat/profiler/parameter_optimization/optimizer_runtime.py,sha256=rXmCOq81o7ZorQOUYociVjuO3NO9CIjFBbwql2u_4H4,2715
370
- nat/profiler/parameter_optimization/parameter_optimizer.py,sha256=CxRFSnl0w0JQvijsY-gszUNxvSrihQ0Jl9ySYClsNFI,6544
370
+ nat/profiler/parameter_optimization/parameter_optimizer.py,sha256=LA2gTBTuezWg5tdqyPA2VjIPkXylgwU9EHpVyaQqBxM,6951
371
371
  nat/profiler/parameter_optimization/parameter_selection.py,sha256=pfnNQIx1evNICgChsOJXIFQHoL1R_kmh_vNDsVMC9kg,3982
372
- nat/profiler/parameter_optimization/pareto_visualizer.py,sha256=IU-4Kw3cVKfDBmXyxtzDf5B325hizMmEYjB9_QJGwD0,15903
372
+ nat/profiler/parameter_optimization/pareto_visualizer.py,sha256=QclLZmmsWINIAh4n0XAKmnIZOqGHTMr-iggZS0kxj-Y,17055
373
373
  nat/profiler/parameter_optimization/prompt_optimizer.py,sha256=_AmdeB1jRamd93qR5UqRy5LweYR3bjnD7zoLxzXYE0k,17658
374
374
  nat/profiler/parameter_optimization/update_helpers.py,sha256=NxWhrGVchbjws85pPd-jS-C14_l70QvVSvEfENndVcY,2339
375
375
  nat/registry_handlers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -470,10 +470,10 @@ nat/utils/reactive/base/observer_base.py,sha256=6BiQfx26EMumotJ3KoVcdmFBYR_fnAss
470
470
  nat/utils/reactive/base/subject_base.py,sha256=UQOxlkZTIeeyYmG5qLtDpNf_63Y7p-doEeUA08_R8ME,2521
471
471
  nat/utils/settings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
472
472
  nat/utils/settings/global_settings.py,sha256=9JaO6pxKT_Pjw6rxJRsRlFCXdVKCl_xUKU2QHZQWWNM,7294
473
- nvidia_nat-1.3.0rc5.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
474
- nvidia_nat-1.3.0rc5.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
475
- nvidia_nat-1.3.0rc5.dist-info/METADATA,sha256=nm0UvCzWa259-7OnT21duAI9yl9EqwKs3lXaxup59OA,10180
476
- nvidia_nat-1.3.0rc5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
477
- nvidia_nat-1.3.0rc5.dist-info/entry_points.txt,sha256=4jCqjyETMpyoWbCBf4GalZU8I_wbstpzwQNezdAVbbo,698
478
- nvidia_nat-1.3.0rc5.dist-info/top_level.txt,sha256=lgJWLkigiVZuZ_O1nxVnD_ziYBwgpE2OStdaCduMEGc,8
479
- nvidia_nat-1.3.0rc5.dist-info/RECORD,,
473
+ nvidia_nat-1.3.0rc6.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
474
+ nvidia_nat-1.3.0rc6.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
475
+ nvidia_nat-1.3.0rc6.dist-info/METADATA,sha256=o6EUDWqT8MzWTPBHPCKymZSNUhSUIadl56OayvNStPA,10242
476
+ nvidia_nat-1.3.0rc6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
477
+ nvidia_nat-1.3.0rc6.dist-info/entry_points.txt,sha256=4jCqjyETMpyoWbCBf4GalZU8I_wbstpzwQNezdAVbbo,698
478
+ nvidia_nat-1.3.0rc6.dist-info/top_level.txt,sha256=lgJWLkigiVZuZ_O1nxVnD_ziYBwgpE2OStdaCduMEGc,8
479
+ nvidia_nat-1.3.0rc6.dist-info/RECORD,,