netra-sdk 0.1.16__tar.gz → 0.1.18__tar.gz

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.

Files changed (47) hide show
  1. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/PKG-INFO +32 -9
  2. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/README.md +27 -6
  3. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/__init__.py +2 -1
  4. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/anonymizer/anonymizer.py +7 -1
  5. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/__init__.py +14 -2
  6. netra_sdk-0.1.18/netra/version.py +1 -0
  7. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/pyproject.toml +6 -3
  8. netra_sdk-0.1.16/netra/version.py +0 -1
  9. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/LICENCE +0 -0
  10. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/anonymizer/__init__.py +0 -0
  11. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/anonymizer/base.py +0 -0
  12. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/anonymizer/fp_anonymizer.py +0 -0
  13. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/config.py +0 -0
  14. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/decorators.py +0 -0
  15. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/exceptions/__init__.py +0 -0
  16. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/exceptions/injection.py +0 -0
  17. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/exceptions/pii.py +0 -0
  18. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/input_scanner.py +0 -0
  19. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/aiohttp/__init__.py +0 -0
  20. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/aiohttp/version.py +0 -0
  21. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/cohere/__init__.py +0 -0
  22. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/cohere/version.py +0 -0
  23. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/fastapi/__init__.py +0 -0
  24. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/fastapi/version.py +0 -0
  25. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/google_genai/__init__.py +0 -0
  26. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/google_genai/config.py +0 -0
  27. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/google_genai/utils.py +0 -0
  28. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/google_genai/version.py +0 -0
  29. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/httpx/__init__.py +0 -0
  30. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/httpx/version.py +0 -0
  31. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/instruments.py +0 -0
  32. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/mistralai/__init__.py +0 -0
  33. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/mistralai/config.py +0 -0
  34. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/mistralai/utils.py +0 -0
  35. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/mistralai/version.py +0 -0
  36. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/openai/__init__.py +0 -0
  37. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/openai/version.py +0 -0
  38. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/openai/wrappers.py +0 -0
  39. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/weaviate/__init__.py +0 -0
  40. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/instrumentation/weaviate/version.py +0 -0
  41. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/pii.py +0 -0
  42. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/processors/__init__.py +0 -0
  43. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/processors/session_span_processor.py +0 -0
  44. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/scanner.py +0 -0
  45. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/session_manager.py +0 -0
  46. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/span_wrapper.py +0 -0
  47. {netra_sdk-0.1.16 → netra_sdk-0.1.18}/netra/tracer.py +0 -0
@@ -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
 
@@ -32,6 +32,21 @@ poetry add netra-sdk
32
32
 
33
33
  Netra SDK supports optional dependencies for enhanced functionality:
34
34
 
35
+ #### Presidio for PII Detection
36
+ To use the PII detection features provided by Netra SDK:
37
+
38
+ ```bash
39
+ pip install 'netra-sdk[presidio]'
40
+ ```
41
+
42
+ Or, using Poetry:
43
+
44
+ ```bash
45
+ poetry add netra-sdk --extras "presidio"
46
+ ```
47
+
48
+
49
+
35
50
  #### LLM-Guard for Prompt Injection Protection
36
51
 
37
52
  To use the full functionality of prompt injection scanning provided by llm-guard:
@@ -56,9 +71,10 @@ Initialize the Netra SDK at the start of your application:
56
71
 
57
72
  ```python
58
73
  from netra import Netra
74
+ from netra.instrumentation.instruments import InstrumentSet
59
75
 
60
76
  # Initialize with default settings
61
- Netra.init(app_name="Your application name")
77
+ Netra.init(app_name="Your application name", instruments={InstrumentSet.OPENAI, InstrumentSet.ANTHROPIC})
62
78
 
63
79
  # Or with custom configuration
64
80
  api_key = "Your API key"
@@ -67,7 +83,8 @@ Netra.init(
67
83
  app_name="Your application name",
68
84
  headers=headers,
69
85
  trace_content=True,
70
- environment="Your Application environment"
86
+ environment="Your Application environment",
87
+ instruments={InstrumentSet.OPENAI, InstrumentSet.ANTHROPIC},
71
88
  )
72
89
  ```
73
90
 
@@ -299,9 +316,10 @@ Track user sessions and add custom context:
299
316
 
300
317
  ```python
301
318
  from netra import Netra
319
+ from netra.instrumentation.instruments import InstrumentSet
302
320
 
303
321
  # Initialize SDK
304
- Netra.init(app_name="My App")
322
+ Netra.init(app_name="My App", instruments={InstrumentSet.OPENAI})
305
323
 
306
324
  # Set session identification
307
325
  Netra.set_session_id("unique-session-id")
@@ -479,13 +497,15 @@ You can also configure the SDK programmatically when initializing:
479
497
 
480
498
  ```python
481
499
  from netra import Netra
500
+ from netra.instrumentation.instruments import InstrumentSet
482
501
 
483
502
  Netra.init(
484
503
  app_name="my-ai-service",
485
504
  environment="production",
486
505
  resource_attributes={"team": "ai", "version": "1.0.0"},
487
506
  trace_content=True,
488
- disable_batch=False
507
+ disable_batch=False,
508
+ instruments={InstrumentSet.OPENAI}
489
509
  )
490
510
  ```
491
511
 
@@ -497,7 +517,7 @@ Control which instrumentations are enabled:
497
517
  from netra import Netra
498
518
  from netra.instrumentation.instruments import InstrumentSet
499
519
 
500
- # Enable specific instruments only
520
+ # Enable specific instruments
501
521
  Netra.init(
502
522
  app_name="Selective App",
503
523
  instruments={
@@ -545,9 +565,10 @@ export NETRA_HEADERS="authorization=Bearer your-token"
545
565
 
546
566
  ```python
547
567
  from netra import Netra
568
+ from netra.instrumentation.instruments import InstrumentSet
548
569
 
549
570
  # Simple initialization - SDK automatically picks up environment variables
550
- Netra.init(app_name="Your App")
571
+ Netra.init(app_name="Your App", instruments={InstrumentSet})
551
572
  # No endpoint configuration needed in code!
552
573
  ```
553
574
 
@@ -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,
@@ -0,0 +1 @@
1
+ __version__ = "0.1.18"
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [project]
6
6
  name = "netra-sdk"
7
- version = "0.1.16"
7
+ version = "0.1.18"
8
8
  description = "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."
9
9
  authors = [
10
10
  {name = "Sooraj Thomas",email = "sooraj@keyvalue.systems"}
@@ -33,7 +33,6 @@ dependencies = [
33
33
  "opentelemetry-sdk>=1.34.0,<2.0.0",
34
34
  "opentelemetry-instrumentation-fastapi>=0.55b1,<1.0.0",
35
35
  "traceloop-sdk>=0.40.7,<0.43.0",
36
- "presidio-analyzer>=2.2.358,<3.0.0",
37
36
  "opentelemetry-instrumentation-httpx>=0.55b1,<1.0.0",
38
37
  "opentelemetry-instrumentation-aiohttp-client>=0.55b1,<1.0.0",
39
38
  "opentelemetry-instrumentation-aio-pika>=0.55b1,<1.0.0",
@@ -91,7 +90,11 @@ include = "netra"
91
90
 
92
91
  [project.optional-dependencies]
93
92
  llm_guard = [
94
- "llm-guard>=0.3.16,<0.4.0",
93
+ "llm-guard==0.3.16",
94
+ ]
95
+ presidio = [
96
+ "presidio-analyzer==2.2.358",
97
+ "presidio-anonymizer==2.2.358",
95
98
  ]
96
99
 
97
100
  [tool.poetry.group.dev.dependencies]
@@ -1 +0,0 @@
1
- __version__ = "0.1.16"
File without changes
File without changes
File without changes
File without changes
File without changes