nvidia-nat-weave 1.4.0a20251015__py3-none-any.whl → 1.4.0a20251022__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/plugins/weave/register.py +5 -1
- nat/plugins/weave/weave_exporter.py +76 -2
- {nvidia_nat_weave-1.4.0a20251015.dist-info → nvidia_nat_weave-1.4.0a20251022.dist-info}/METADATA +2 -2
- nvidia_nat_weave-1.4.0a20251022.dist-info/RECORD +11 -0
- nvidia_nat_weave-1.4.0a20251015.dist-info/RECORD +0 -11
- {nvidia_nat_weave-1.4.0a20251015.dist-info → nvidia_nat_weave-1.4.0a20251022.dist-info}/WHEEL +0 -0
- {nvidia_nat_weave-1.4.0a20251015.dist-info → nvidia_nat_weave-1.4.0a20251022.dist-info}/entry_points.txt +0 -0
- {nvidia_nat_weave-1.4.0a20251015.dist-info → nvidia_nat_weave-1.4.0a20251022.dist-info}/licenses/LICENSE-3rd-party.txt +0 -0
- {nvidia_nat_weave-1.4.0a20251015.dist-info → nvidia_nat_weave-1.4.0a20251022.dist-info}/licenses/LICENSE.md +0 -0
- {nvidia_nat_weave-1.4.0a20251015.dist-info → nvidia_nat_weave-1.4.0a20251022.dist-info}/top_level.txt +0 -0
nat/plugins/weave/register.py
CHANGED
|
@@ -27,7 +27,11 @@ logger = logging.getLogger(__name__)
|
|
|
27
27
|
class WeaveTelemetryExporter(TelemetryExporterBaseConfig, name="weave"):
|
|
28
28
|
"""A telemetry exporter to transmit traces to Weights & Biases Weave using OpenTelemetry."""
|
|
29
29
|
project: str = Field(description="The W&B project name.")
|
|
30
|
-
entity: str | None = Field(default=None,
|
|
30
|
+
entity: str | None = Field(default=None,
|
|
31
|
+
description="The W&B username or team name.",
|
|
32
|
+
deprecated=('This field is deprecated and will be removed in future versions. '
|
|
33
|
+
'This value is set automatically by the weave library, and setting it will '
|
|
34
|
+
'have no effect.'))
|
|
31
35
|
redact_pii: bool = Field(default=False, description="Whether to redact PII from the traces.")
|
|
32
36
|
redact_pii_fields: list[str] | None = Field(
|
|
33
37
|
default=None,
|
|
@@ -16,12 +16,14 @@
|
|
|
16
16
|
import logging
|
|
17
17
|
from collections.abc import Generator
|
|
18
18
|
from contextlib import contextmanager
|
|
19
|
+
from typing import Any
|
|
19
20
|
|
|
20
21
|
from nat.data_models.intermediate_step import IntermediateStep
|
|
21
22
|
from nat.data_models.span import Span
|
|
22
23
|
from nat.observability.exporter.base_exporter import IsolatedAttribute
|
|
23
24
|
from nat.observability.exporter.span_exporter import SpanExporter
|
|
24
25
|
from nat.utils.log_utils import LogFilter
|
|
26
|
+
from nat.utils.string_utils import truncate_string
|
|
25
27
|
from nat.utils.type_utils import override
|
|
26
28
|
from weave.trace.context import weave_client_context
|
|
27
29
|
from weave.trace.context.call_context import get_current_call
|
|
@@ -142,9 +144,9 @@ class WeaveExporter(SpanExporter[Span, Span]):
|
|
|
142
144
|
# Generate a meaningful operation name based on event type
|
|
143
145
|
event_type = step.payload.event_type.split(".")[-1]
|
|
144
146
|
if step.payload.name:
|
|
145
|
-
op_name = f"
|
|
147
|
+
op_name = f"nat.{event_type}.{step.payload.name}"
|
|
146
148
|
else:
|
|
147
|
-
op_name = f"
|
|
149
|
+
op_name = f"nat.{event_type}"
|
|
148
150
|
|
|
149
151
|
# Create input dictionary
|
|
150
152
|
inputs = {}
|
|
@@ -152,6 +154,7 @@ class WeaveExporter(SpanExporter[Span, Span]):
|
|
|
152
154
|
try:
|
|
153
155
|
# Add the input to the Weave call
|
|
154
156
|
inputs["input"] = step.payload.data.input
|
|
157
|
+
self._extract_input_message(step.payload.data.input, inputs)
|
|
155
158
|
except Exception:
|
|
156
159
|
# If serialization fails, use string representation
|
|
157
160
|
inputs["input"] = str(step.payload.data.input)
|
|
@@ -176,6 +179,76 @@ class WeaveExporter(SpanExporter[Span, Span]):
|
|
|
176
179
|
|
|
177
180
|
return call
|
|
178
181
|
|
|
182
|
+
def _extract_input_message(self, input_data: Any, inputs: dict[str, Any]) -> None:
|
|
183
|
+
"""
|
|
184
|
+
Extract message content from input data and add to inputs dictionary.
|
|
185
|
+
Also handles websocket mode where message is located at messages[0].content[0].text.
|
|
186
|
+
|
|
187
|
+
Args:
|
|
188
|
+
input_data: The raw input data from the request
|
|
189
|
+
inputs: Dictionary to populate with extracted message content
|
|
190
|
+
"""
|
|
191
|
+
# Extract message content if input has messages attribute
|
|
192
|
+
messages = getattr(input_data, 'messages', [])
|
|
193
|
+
if messages:
|
|
194
|
+
content = messages[0].content
|
|
195
|
+
if isinstance(content, list) and content:
|
|
196
|
+
inputs["input_message"] = getattr(content[0], 'text', content[0])
|
|
197
|
+
else:
|
|
198
|
+
inputs["input_message"] = content
|
|
199
|
+
|
|
200
|
+
def _extract_output_message(self, output_data: Any, outputs: dict[str, Any]) -> None:
|
|
201
|
+
"""
|
|
202
|
+
Extract message content from various response formats and add a preview to the outputs dictionary.
|
|
203
|
+
No data is added to the outputs dictionary if the output format is not supported.
|
|
204
|
+
|
|
205
|
+
Supported output formats for message content include:
|
|
206
|
+
|
|
207
|
+
- output.choices[0].message.content /chat endpoint
|
|
208
|
+
- output.value /generate endpoint
|
|
209
|
+
- output[0].choices[0].message.content chat WS schema
|
|
210
|
+
- output[0].choices[0].delta.content chat_stream WS schema, /chat/stream endpoint
|
|
211
|
+
- output[0].value generate & generate_stream WS schema, /generate/stream endpoint
|
|
212
|
+
|
|
213
|
+
Args:
|
|
214
|
+
output_data: The raw output data from the response
|
|
215
|
+
outputs: Dictionary to populate with extracted message content.
|
|
216
|
+
"""
|
|
217
|
+
# Handle choices-keyed output object for /chat completion endpoint
|
|
218
|
+
choices = getattr(output_data, 'choices', None)
|
|
219
|
+
if choices:
|
|
220
|
+
outputs["output_message"] = truncate_string(choices[0].message.content)
|
|
221
|
+
return
|
|
222
|
+
|
|
223
|
+
# Handle value-keyed output object for union types common for /generate completion endpoint
|
|
224
|
+
value = getattr(output_data, 'value', None)
|
|
225
|
+
if value:
|
|
226
|
+
outputs["output_message"] = truncate_string(value)
|
|
227
|
+
return
|
|
228
|
+
|
|
229
|
+
# Handle list-based outputs (streaming or websocket)
|
|
230
|
+
if not isinstance(output_data, list) or not output_data:
|
|
231
|
+
return
|
|
232
|
+
|
|
233
|
+
choices = getattr(output_data[0], 'choices', None)
|
|
234
|
+
if choices:
|
|
235
|
+
# chat websocket schema
|
|
236
|
+
message = getattr(choices[0], 'message', None)
|
|
237
|
+
if message:
|
|
238
|
+
outputs["output_message"] = truncate_string(getattr(message, 'content', None))
|
|
239
|
+
return
|
|
240
|
+
|
|
241
|
+
# chat_stream websocket schema and /chat/stream completion endpoint
|
|
242
|
+
delta = getattr(choices[0], 'delta', None)
|
|
243
|
+
if delta:
|
|
244
|
+
outputs["output_preview"] = truncate_string(getattr(delta, 'content', None))
|
|
245
|
+
return
|
|
246
|
+
|
|
247
|
+
# generate & generate_stream websocket schema, and /generate/stream completion endpoint
|
|
248
|
+
value = getattr(output_data[0], 'value', None)
|
|
249
|
+
if value:
|
|
250
|
+
outputs["output_preview"] = truncate_string(str(value))
|
|
251
|
+
|
|
179
252
|
def _finish_weave_call(self, step: IntermediateStep) -> None:
|
|
180
253
|
"""
|
|
181
254
|
Finish a previously created Weave call.
|
|
@@ -196,6 +269,7 @@ class WeaveExporter(SpanExporter[Span, Span]):
|
|
|
196
269
|
try:
|
|
197
270
|
# Add the output to the Weave call
|
|
198
271
|
outputs["output"] = step.payload.data.output
|
|
272
|
+
self._extract_output_message(step.payload.data.output, outputs)
|
|
199
273
|
except Exception:
|
|
200
274
|
# If serialization fails, use string representation
|
|
201
275
|
outputs["output"] = str(step.payload.data.output)
|
{nvidia_nat_weave-1.4.0a20251015.dist-info → nvidia_nat_weave-1.4.0a20251022.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nvidia-nat-weave
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.0a20251022
|
|
4
4
|
Summary: Subpackage for Weave integration in NeMo Agent toolkit
|
|
5
5
|
Author: NVIDIA Corporation
|
|
6
6
|
Maintainer: NVIDIA Corporation
|
|
@@ -16,7 +16,7 @@ Requires-Python: <3.14,>=3.11
|
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE-3rd-party.txt
|
|
18
18
|
License-File: LICENSE.md
|
|
19
|
-
Requires-Dist: nvidia-nat==v1.4.
|
|
19
|
+
Requires-Dist: nvidia-nat==v1.4.0a20251022
|
|
20
20
|
Requires-Dist: presidio-analyzer~=2.2
|
|
21
21
|
Requires-Dist: presidio-anonymizer~=2.2
|
|
22
22
|
Requires-Dist: weave==0.52.6
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
nat/meta/pypi.md,sha256=FVQR5lfZjqZHm4VWMmQJYgZbwJJjrfQZgEqHscDuMR8,1121
|
|
2
|
+
nat/plugins/weave/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
nat/plugins/weave/register.py,sha256=EWd3c2eLuNeXQk8CWM5sbP9SUtj59hvhLZaEAQiqbRg,3252
|
|
4
|
+
nat/plugins/weave/weave_exporter.py,sha256=zgR4-_Mv8PKAH7WvWwbL51Q89deH_2oiqkSrXd82KHg,12259
|
|
5
|
+
nvidia_nat_weave-1.4.0a20251022.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
|
|
6
|
+
nvidia_nat_weave-1.4.0a20251022.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
7
|
+
nvidia_nat_weave-1.4.0a20251022.dist-info/METADATA,sha256=z2z8mUvT_lFV4C06cYjpLMUxPbxSMQt518C0tUCLnz0,2014
|
|
8
|
+
nvidia_nat_weave-1.4.0a20251022.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
+
nvidia_nat_weave-1.4.0a20251022.dist-info/entry_points.txt,sha256=xg4vW3wKsOLfHa-QR6JqWnq3DmdfI_z9IZfg4I9thTY,56
|
|
10
|
+
nvidia_nat_weave-1.4.0a20251022.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
|
|
11
|
+
nvidia_nat_weave-1.4.0a20251022.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
nat/meta/pypi.md,sha256=FVQR5lfZjqZHm4VWMmQJYgZbwJJjrfQZgEqHscDuMR8,1121
|
|
2
|
-
nat/plugins/weave/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
nat/plugins/weave/register.py,sha256=NvK8roew0XjgrhVVw7sDKqZcjpy-LvNIv3UYEFCElB0,2927
|
|
4
|
-
nat/plugins/weave/weave_exporter.py,sha256=5JygAVkNKDl_uj-YRTIrN8w4Si_H1vOVBh7OCRuCzf4,8798
|
|
5
|
-
nvidia_nat_weave-1.4.0a20251015.dist-info/licenses/LICENSE-3rd-party.txt,sha256=fOk5jMmCX9YoKWyYzTtfgl-SUy477audFC5hNY4oP7Q,284609
|
|
6
|
-
nvidia_nat_weave-1.4.0a20251015.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
7
|
-
nvidia_nat_weave-1.4.0a20251015.dist-info/METADATA,sha256=w1mYyaZjE9R9Qowthv4-pqyGuq_2hDc4Sz9myfN_tXo,2014
|
|
8
|
-
nvidia_nat_weave-1.4.0a20251015.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
-
nvidia_nat_weave-1.4.0a20251015.dist-info/entry_points.txt,sha256=xg4vW3wKsOLfHa-QR6JqWnq3DmdfI_z9IZfg4I9thTY,56
|
|
10
|
-
nvidia_nat_weave-1.4.0a20251015.dist-info/top_level.txt,sha256=8-CJ2cP6-f0ZReXe5Hzqp-5pvzzHz-5Ds5H2bGqh1-U,4
|
|
11
|
-
nvidia_nat_weave-1.4.0a20251015.dist-info/RECORD,,
|
{nvidia_nat_weave-1.4.0a20251015.dist-info → nvidia_nat_weave-1.4.0a20251022.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|