netra-sdk 0.1.16__py3-none-any.whl → 0.1.18__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
@@ -2,7 +2,7 @@ import logging
2
2
  import threading
3
3
  from typing import Any, Dict, Optional, Set
4
4
 
5
- from netra.instrumentation.instruments import NetraInstruments
5
+ from netra.instrumentation.instruments import InstrumentSet, NetraInstruments
6
6
 
7
7
  from .config import Config
8
8
 
@@ -70,6 +70,7 @@ class Netra:
70
70
 
71
71
  # Instrument all supported modules
72
72
  # Pass trace_content flag to instrumentors that can capture prompts/completions
73
+
73
74
  init_instrumentations(
74
75
  should_enrich_metrics=True,
75
76
  base64_image_uploader=None,
@@ -8,7 +8,13 @@ texts while maintaining privacy.
8
8
 
9
9
  from typing import Callable, List, Optional
10
10
 
11
- from presidio_analyzer.recognizer_result import RecognizerResult
11
+ try:
12
+ from presidio_analyzer.recognizer_result import RecognizerResult
13
+ except Exception:
14
+ raise ImportError(
15
+ "PII Detetcion requires the 'presidio' packages: Install them explicitly as they are not available with the base SDK. Use pip install 'netra-sdk[presidio]' to install them."
16
+ )
17
+
12
18
 
13
19
  from .base import AnonymizationResult, BaseAnonymizer
14
20
  from .fp_anonymizer import FormatPreservingEmailAnonymizer
@@ -31,6 +31,20 @@ def init_instrumentations(
31
31
  netra_custom_block_instruments.add(getattr(CustomInstruments, instrument.name))
32
32
  else:
33
33
  traceloop_block_instruments.add(getattr(Instruments, instrument.name))
34
+
35
+ # If no instruments are provided for instrumentation
36
+ if instruments is None:
37
+ traceloop_block_instruments = set(Instruments)
38
+ netra_custom_block_instruments = set(CustomInstruments)
39
+
40
+ # If only custom instruments from netra are provided for instrumentation
41
+ if instruments is not None and not traceloop_instruments and not traceloop_block_instruments:
42
+ traceloop_block_instruments = set(Instruments)
43
+
44
+ # If only traceloop instruments are provided for instrumentation
45
+ if instruments is not None and not netra_custom_instruments and not netra_custom_block_instruments:
46
+ netra_custom_block_instruments = set(CustomInstruments)
47
+
34
48
  traceloop_block_instruments.update(
35
49
  {
36
50
  Instruments.WEAVIATE,
@@ -40,8 +54,6 @@ def init_instrumentations(
40
54
  Instruments.OPENAI,
41
55
  }
42
56
  )
43
- if instruments is not None and traceloop_instruments is None and traceloop_block_instruments is None:
44
- traceloop_block_instruments = set(Instruments)
45
57
 
46
58
  init_instrumentations(
47
59
  should_enrich_metrics=should_enrich_metrics,
netra/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.16"
1
+ __version__ = "0.1.18"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: netra-sdk
3
- Version: 0.1.16
3
+ Version: 0.1.18
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
@@ -18,7 +18,8 @@ Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: 3.13
19
19
  Classifier: Typing :: Typed
20
20
  Provides-Extra: llm-guard
21
- Requires-Dist: llm-guard (>=0.3.16,<0.4.0) ; extra == "llm-guard"
21
+ Provides-Extra: presidio
22
+ Requires-Dist: llm-guard (==0.3.16) ; extra == "llm-guard"
22
23
  Requires-Dist: opentelemetry-api (>=1.34.0,<2.0.0)
23
24
  Requires-Dist: opentelemetry-instrumentation-aio-pika (>=0.55b1,<1.0.0)
24
25
  Requires-Dist: opentelemetry-instrumentation-aiohttp-client (>=0.55b1,<1.0.0)
@@ -66,7 +67,8 @@ Requires-Dist: opentelemetry-instrumentation-tortoiseorm (>=0.55b1,<1.0.0)
66
67
  Requires-Dist: opentelemetry-instrumentation-urllib (>=0.55b1,<1.0.0)
67
68
  Requires-Dist: opentelemetry-instrumentation-urllib3 (>=0.55b1,<1.0.0)
68
69
  Requires-Dist: opentelemetry-sdk (>=1.34.0,<2.0.0)
69
- Requires-Dist: presidio-analyzer (>=2.2.358,<3.0.0)
70
+ Requires-Dist: presidio-analyzer (==2.2.358) ; extra == "presidio"
71
+ Requires-Dist: presidio-anonymizer (==2.2.358) ; extra == "presidio"
70
72
  Requires-Dist: traceloop-sdk (>=0.40.7,<0.43.0)
71
73
  Project-URL: Bug Tracker, https://github.com/KeyValueSoftwareSystems/netra-sdk-py/issues
72
74
  Project-URL: Documentation, https://github.com/KeyValueSoftwareSystems/netra-sdk-py/blob/main/README.md
@@ -108,6 +110,21 @@ poetry add netra-sdk
108
110
 
109
111
  Netra SDK supports optional dependencies for enhanced functionality:
110
112
 
113
+ #### Presidio for PII Detection
114
+ To use the PII detection features provided by Netra SDK:
115
+
116
+ ```bash
117
+ pip install 'netra-sdk[presidio]'
118
+ ```
119
+
120
+ Or, using Poetry:
121
+
122
+ ```bash
123
+ poetry add netra-sdk --extras "presidio"
124
+ ```
125
+
126
+
127
+
111
128
  #### LLM-Guard for Prompt Injection Protection
112
129
 
113
130
  To use the full functionality of prompt injection scanning provided by llm-guard:
@@ -132,9 +149,10 @@ Initialize the Netra SDK at the start of your application:
132
149
 
133
150
  ```python
134
151
  from netra import Netra
152
+ from netra.instrumentation.instruments import InstrumentSet
135
153
 
136
154
  # Initialize with default settings
137
- Netra.init(app_name="Your application name")
155
+ Netra.init(app_name="Your application name", instruments={InstrumentSet.OPENAI, InstrumentSet.ANTHROPIC})
138
156
 
139
157
  # Or with custom configuration
140
158
  api_key = "Your API key"
@@ -143,7 +161,8 @@ Netra.init(
143
161
  app_name="Your application name",
144
162
  headers=headers,
145
163
  trace_content=True,
146
- environment="Your Application environment"
164
+ environment="Your Application environment",
165
+ instruments={InstrumentSet.OPENAI, InstrumentSet.ANTHROPIC},
147
166
  )
148
167
  ```
149
168
 
@@ -375,9 +394,10 @@ Track user sessions and add custom context:
375
394
 
376
395
  ```python
377
396
  from netra import Netra
397
+ from netra.instrumentation.instruments import InstrumentSet
378
398
 
379
399
  # Initialize SDK
380
- Netra.init(app_name="My App")
400
+ Netra.init(app_name="My App", instruments={InstrumentSet.OPENAI})
381
401
 
382
402
  # Set session identification
383
403
  Netra.set_session_id("unique-session-id")
@@ -555,13 +575,15 @@ You can also configure the SDK programmatically when initializing:
555
575
 
556
576
  ```python
557
577
  from netra import Netra
578
+ from netra.instrumentation.instruments import InstrumentSet
558
579
 
559
580
  Netra.init(
560
581
  app_name="my-ai-service",
561
582
  environment="production",
562
583
  resource_attributes={"team": "ai", "version": "1.0.0"},
563
584
  trace_content=True,
564
- disable_batch=False
585
+ disable_batch=False,
586
+ instruments={InstrumentSet.OPENAI}
565
587
  )
566
588
  ```
567
589
 
@@ -573,7 +595,7 @@ Control which instrumentations are enabled:
573
595
  from netra import Netra
574
596
  from netra.instrumentation.instruments import InstrumentSet
575
597
 
576
- # Enable specific instruments only
598
+ # Enable specific instruments
577
599
  Netra.init(
578
600
  app_name="Selective App",
579
601
  instruments={
@@ -621,9 +643,10 @@ export NETRA_HEADERS="authorization=Bearer your-token"
621
643
 
622
644
  ```python
623
645
  from netra import Netra
646
+ from netra.instrumentation.instruments import InstrumentSet
624
647
 
625
648
  # Simple initialization - SDK automatically picks up environment variables
626
- Netra.init(app_name="Your App")
649
+ Netra.init(app_name="Your App", instruments={InstrumentSet})
627
650
  # No endpoint configuration needed in code!
628
651
  ```
629
652
 
@@ -1,6 +1,6 @@
1
- netra/__init__.py,sha256=8N0U8USfoep2rEnQEPyyFrd1nmuMgpmTSSTyugaW528,5376
1
+ netra/__init__.py,sha256=49R2bZrVu30HhpE3gfpu0b5C5cNovC6WyNyUwHCOfQ8,5392
2
2
  netra/anonymizer/__init__.py,sha256=KeGPPZqKVZbtkbirEKYTYhj6aZHlakjdQhD7QHqBRio,133
3
- netra/anonymizer/anonymizer.py,sha256=1VeYAsFpF_tYDlqJF-Q82-ZXGOR4YWBqrKUsRw3qOrA,3539
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
6
  netra/config.py,sha256=S9GsCvwtakrmryAaV-AhyVB_wAQ6tjwPLLZQemLgXko,5006
@@ -9,7 +9,7 @@ netra/exceptions/__init__.py,sha256=uDgcBxmC4WhdS7HRYQk_TtJyxH1s1o6wZmcsnSHLAcM,
9
9
  netra/exceptions/injection.py,sha256=ke4eUXRYUFJkMZgdSyPPkPt5PdxToTI6xLEBI0hTWUQ,1332
10
10
  netra/exceptions/pii.py,sha256=MT4p_x-zH3VtYudTSxw1Z9qQZADJDspq64WrYqSWlZc,2438
11
11
  netra/input_scanner.py,sha256=bzP3s7YudGHQrIbUgQGrcIBEJ6CmOewzuYNSu75cVXM,4988
12
- netra/instrumentation/__init__.py,sha256=Mz7BlRp4zgKAD3oLBGfBzh5naVVgAP0sLw4ISDydhLw,39567
12
+ netra/instrumentation/__init__.py,sha256=ZORhcso04LPD6-Y7oPsh74rY-jwz1unsfYZBcP--SzM,40081
13
13
  netra/instrumentation/aiohttp/__init__.py,sha256=M1kuF0R3gKY5rlbhEC1AR13UWHelmfokluL2yFysKWc,14398
14
14
  netra/instrumentation/aiohttp/version.py,sha256=Zy-0Aukx-HS_Mo3NKPWg-hlUoWKDzS0w58gLoVtJec8,24
15
15
  netra/instrumentation/cohere/__init__.py,sha256=3XwmCAZwZiMkHdNN3YvcBOLsNCx80ymbU31TyMzv1IY,17685
@@ -39,8 +39,8 @@ netra/scanner.py,sha256=wqjMZnEbVvrGMiUSI352grUyHpkk94oBfHfMiXPhpGU,3866
39
39
  netra/session_manager.py,sha256=EVcnWcSj4NdkH--HmqHx0mmzivQiM4GCyFLu6lwi33M,6252
40
40
  netra/span_wrapper.py,sha256=DA5jjXkHBUJ8_mdlYP06rcZzFoSih4gdP71Wwr3btcQ,8104
41
41
  netra/tracer.py,sha256=In5QPVLz_6BxrolWpav9EuR9_hirD2UUIlyY75QUaKk,3450
42
- netra/version.py,sha256=yF88-8vL8keLe6gCTumymw0UoMkWkSrJnzLru4zBCLQ,23
43
- netra_sdk-0.1.16.dist-info/LICENCE,sha256=8B_UoZ-BAl0AqiHAHUETCgd3I2B9yYJ1WEQtVb_qFMA,11359
44
- netra_sdk-0.1.16.dist-info/METADATA,sha256=5Cq-WcgwKPAsUaikTeP1qjO4MixYZ_VhLXSTvNJQpf0,25352
45
- netra_sdk-0.1.16.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
46
- netra_sdk-0.1.16.dist-info/RECORD,,
42
+ netra/version.py,sha256=6BiuMUkhwQp6bzUZSF8np8F1NwCltEtK0sPBF__tepU,23
43
+ netra_sdk-0.1.18.dist-info/LICENCE,sha256=8B_UoZ-BAl0AqiHAHUETCgd3I2B9yYJ1WEQtVb_qFMA,11359
44
+ netra_sdk-0.1.18.dist-info/METADATA,sha256=xANrdroAsDTktKVUyaTO6-c6r9Pja6XIMda5-Zhn0Zo,26133
45
+ netra_sdk-0.1.18.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
46
+ netra_sdk-0.1.18.dist-info/RECORD,,