netra-sdk 0.1.40__py3-none-any.whl → 0.1.42__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.

Potentially problematic release.


This version of netra-sdk might be problematic. Click here for more details.

netra/__init__.py CHANGED
@@ -9,7 +9,7 @@ from opentelemetry.trace import SpanKind
9
9
 
10
10
  from netra.instrumentation.instruments import InstrumentSet, NetraInstruments
11
11
 
12
- from .config import Config, ConversationType
12
+ from .config import Config
13
13
 
14
14
  # Instrumentor functions
15
15
  from .instrumentation import init_instrumentations
@@ -249,13 +249,13 @@ class Netra:
249
249
  logger.warning("Both event_name and attributes must be provided for custom events.")
250
250
 
251
251
  @classmethod
252
- def add_conversation(cls, type: ConversationType, field_name: str, value: Any) -> None:
252
+ def add_conversation(cls, conversation_type: ConversationType, role: str, content: Any) -> None:
253
253
  """
254
254
  Append a conversation entry and set span attribute 'conversation' as an array.
255
255
  If a conversation array already exists for the current active span, this appends
256
256
  to it; otherwise, it initializes a new array.
257
257
  """
258
- SessionManager.add_conversation(type=type, field_name=field_name, value=value)
258
+ SessionManager.add_conversation(conversation_type=conversation_type, role=role, content=content)
259
259
 
260
260
  @classmethod
261
261
  def start_span(
netra/config.py CHANGED
@@ -1,6 +1,5 @@
1
1
  import json
2
2
  import os
3
- from enum import Enum
4
3
  from typing import Any, Dict, List, Optional
5
4
 
6
5
  from opentelemetry.util.re import parse_env_headers
@@ -8,12 +7,6 @@ from opentelemetry.util.re import parse_env_headers
8
7
  from netra.version import __version__
9
8
 
10
9
 
11
- class ConversationType(str, Enum):
12
- INPUT = "input"
13
- OUTPUT = "output"
14
- SYSTEM = "system"
15
-
16
-
17
10
  class Config:
18
11
  """
19
12
  Holds configuration options for the tracer:
netra/session_manager.py CHANGED
@@ -20,7 +20,6 @@ logger = logging.getLogger(__name__)
20
20
  class ConversationType(str, Enum):
21
21
  INPUT = "input"
22
22
  OUTPUT = "output"
23
- SYSTEM = "system"
24
23
 
25
24
 
26
25
  class SessionManager:
@@ -262,7 +261,7 @@ class SessionManager:
262
261
  logger.exception(f"Failed to add custom event: {name} - {e}")
263
262
 
264
263
  @staticmethod
265
- def add_conversation(type: ConversationType, field_name: str, value: Any) -> None:
264
+ def add_conversation(conversation_type: ConversationType, role: str, content: Any) -> None:
266
265
  """
267
266
  Append a conversation entry and set span attribute 'conversation' as an array.
268
267
 
@@ -274,17 +273,17 @@ class SessionManager:
274
273
  """
275
274
 
276
275
  # Hard runtime validation of input types and values
277
- if not isinstance(type, ConversationType):
278
- raise TypeError("type must be a ConversationType enum value (input, output, system)")
279
- normalized_type = type.value
276
+ if not isinstance(conversation_type, ConversationType):
277
+ raise TypeError("conversation_type must be a ConversationType enum value (input, output, system)")
278
+ normalized_type = conversation_type.value
280
279
 
281
- if not isinstance(field_name, str):
282
- raise TypeError(f"field_name must be a string, got {type(field_name)}")
283
- if not field_name:
284
- raise ValueError("field_name must be a non-empty string")
280
+ if not isinstance(role, str):
281
+ raise TypeError(f"role must be a string, got {type(role)}")
282
+ if not role:
283
+ raise ValueError("role must be a non-empty string")
285
284
 
286
- if value is None:
287
- raise ValueError("value must not be None")
285
+ if not content:
286
+ raise ValueError("content must not be empty")
288
287
 
289
288
  try:
290
289
  span = trace.get_current_span()
@@ -313,7 +312,12 @@ class SessionManager:
313
312
  existing = []
314
313
 
315
314
  # Append new entry
316
- entry: Dict[str, Any] = {"type": normalized_type, "field_name": field_name, "value": value}
315
+ entry: Dict[str, Any] = {"type": normalized_type, "role": role, "content": content}
316
+ # Add value_type and media_type based on value type for backend parsing
317
+ if isinstance(content, str):
318
+ entry["format"] = "text"
319
+ elif isinstance(content, dict):
320
+ entry["format"] = "json"
317
321
  existing.append(entry)
318
322
 
319
323
  SessionManager.set_attribute_on_active_span("conversation", existing)
netra/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.40"
1
+ __version__ = "0.1.42"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: netra-sdk
3
- Version: 0.1.40
3
+ Version: 0.1.42
4
4
  Summary: A Python SDK for AI application observability that provides OpenTelemetry-based monitoring, tracing, and PII protection for LLM and vector database applications. Enables easy instrumentation, session tracking, and privacy-focused data collection for AI systems in production environments.
5
5
  License: Apache-2.0
6
6
  Keywords: netra,tracing,observability,sdk,ai,llm,vector,database
@@ -73,8 +73,8 @@ Requires-Dist: stanza (>=1.10.1,<2.0.0) ; extra == "presidio"
73
73
  Requires-Dist: traceloop-sdk (>=0.40.7,<0.43.0)
74
74
  Requires-Dist: transformers (==4.51.3) ; extra == "presidio"
75
75
  Project-URL: Changelog, https://github.com/KeyValueSoftwareSystems/netra-sdk-py/blob/main/CHANGELOG.md
76
- Project-URL: Documentation, https://github.com/KeyValueSoftwareSystems/netra-sdk-py/blob/main/README.md
77
- Project-URL: Homepage, https://github.com/KeyValueSoftwareSystems/netra-sdk-py
76
+ Project-URL: Documentation, https://docs.getnetra.ai/introduction
77
+ Project-URL: Homepage, https://getnetra.ai/
78
78
  Project-URL: Repository, https://github.com/KeyValueSoftwareSystems/netra-sdk-py
79
79
  Description-Content-Type: text/markdown
80
80
 
@@ -1,9 +1,9 @@
1
- netra/__init__.py,sha256=q8ROk7l-ZWaS8JtAS8loSubKlQGcgynUQDgt5MA_XO8,10344
1
+ netra/__init__.py,sha256=-eEBq3ndX3JAWDo4_Ra0L19KrTfrJhNDjlAwChb3_IA,10353
2
2
  netra/anonymizer/__init__.py,sha256=KeGPPZqKVZbtkbirEKYTYhj6aZHlakjdQhD7QHqBRio,133
3
3
  netra/anonymizer/anonymizer.py,sha256=IcrYkdwWrFauGWUeAW-0RwrSUM8VSZCFNtoywZhvIqU,3778
4
4
  netra/anonymizer/base.py,sha256=ytPxHCUD2OXlEY6fNTuMmwImNdIjgj294I41FIgoXpU,5946
5
5
  netra/anonymizer/fp_anonymizer.py,sha256=_6svIYmE0eejdIMkhKBUWCNjGtGimtrGtbLvPSOp8W4,6493
6
- netra/config.py,sha256=UvWJ0Vny4DYJseC7X3a_NoXG0it10qAl0wse26VG73Q,7016
6
+ netra/config.py,sha256=51m8R0NoOrw58gMV7arOniEuFdJ7EIu3PNdFtIQ5xfg,6893
7
7
  netra/decorators.py,sha256=qZFHrwdj10FsTFqggo3XjdGB12aMxsrrDMMmslDqZ-0,17424
8
8
  netra/exceptions/__init__.py,sha256=uDgcBxmC4WhdS7HRYQk_TtJyxH1s1o6wZmcsnSHLAcM,174
9
9
  netra/exceptions/injection.py,sha256=ke4eUXRYUFJkMZgdSyPPkPt5PdxToTI6xLEBI0hTWUQ,1332
@@ -45,11 +45,11 @@ netra/processors/instrumentation_span_processor.py,sha256=VzurzwtGleFltxzKD_gjVk
45
45
  netra/processors/scrubbing_span_processor.py,sha256=dJ86Ncmjvmrhm_uAdGTwcGvRpZbVVWqD9AOFwEMWHZY,6701
46
46
  netra/processors/session_span_processor.py,sha256=qcsBl-LnILWefsftI8NQhXDGb94OWPc8LvzhVA0JS_c,2432
47
47
  netra/scanner.py,sha256=kyDpeZiscCPb6pjuhS-sfsVj-dviBFRepdUWh0sLoEY,11554
48
- netra/session_manager.py,sha256=d86RP2z3QxdjZtk-nOeaB9R3Q57d4BaSkdVWKHn8hM0,12443
48
+ netra/session_manager.py,sha256=iU5UG_Y-fPMoyRxjfEqYCBxzzmcSVJi411Ni6gL7g9w,12683
49
49
  netra/span_wrapper.py,sha256=IygQX78xQRlL_Z1MfKfUbv0okihx92qNClnRlYFtRNc,8004
50
50
  netra/tracer.py,sha256=FJO8Cine-WL9K_4wn6RVjQOgX6c1JCp_8QowUbRSVHk,7718
51
- netra/version.py,sha256=bRKE9C91TYGzTq0wxI4905SCxXVaXJVP1EuahhGjfCQ,23
52
- netra_sdk-0.1.40.dist-info/LICENCE,sha256=8B_UoZ-BAl0AqiHAHUETCgd3I2B9yYJ1WEQtVb_qFMA,11359
53
- netra_sdk-0.1.40.dist-info/METADATA,sha256=YnbDinheAFn1vilWTqQHxi0oU1kxFSIxBGNPUtnm_I0,28210
54
- netra_sdk-0.1.40.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
55
- netra_sdk-0.1.40.dist-info/RECORD,,
51
+ netra/version.py,sha256=a0ON039K5sX117g1thh7kP35cYMBjBhhhU9A-PERuT0,23
52
+ netra_sdk-0.1.42.dist-info/LICENCE,sha256=8B_UoZ-BAl0AqiHAHUETCgd3I2B9yYJ1WEQtVb_qFMA,11359
53
+ netra_sdk-0.1.42.dist-info/METADATA,sha256=ogWH-5_FBACadeZamwnUqoiAiIkRclRg5561U_a0Lqc,28137
54
+ netra_sdk-0.1.42.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
55
+ netra_sdk-0.1.42.dist-info/RECORD,,