lmnr 0.4.44__tar.gz → 0.4.45__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.
Files changed (32) hide show
  1. {lmnr-0.4.44 → lmnr-0.4.45}/PKG-INFO +8 -11
  2. {lmnr-0.4.44 → lmnr-0.4.45}/pyproject.toml +9 -12
  3. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/__init__.py +1 -0
  4. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/openllmetry_sdk/tracing/attributes.py +1 -0
  5. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/openllmetry_sdk/tracing/tracing.py +4 -0
  6. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/sdk/laminar.py +48 -14
  7. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/sdk/types.py +6 -0
  8. {lmnr-0.4.44 → lmnr-0.4.45}/LICENSE +0 -0
  9. {lmnr-0.4.44 → lmnr-0.4.45}/README.md +0 -0
  10. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/cli.py +0 -0
  11. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/openllmetry_sdk/.flake8 +0 -0
  12. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/openllmetry_sdk/.python-version +0 -0
  13. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/openllmetry_sdk/__init__.py +0 -0
  14. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/openllmetry_sdk/config/__init__.py +0 -0
  15. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/openllmetry_sdk/decorators/__init__.py +0 -0
  16. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/openllmetry_sdk/decorators/base.py +0 -0
  17. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/openllmetry_sdk/instruments.py +0 -0
  18. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/openllmetry_sdk/tracing/__init__.py +0 -0
  19. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/openllmetry_sdk/tracing/content_allow_list.py +0 -0
  20. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/openllmetry_sdk/tracing/context_manager.py +0 -0
  21. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/openllmetry_sdk/utils/__init__.py +0 -0
  22. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/openllmetry_sdk/utils/in_memory_span_exporter.py +0 -0
  23. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/openllmetry_sdk/utils/json_encoder.py +0 -0
  24. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/openllmetry_sdk/utils/package_check.py +0 -0
  25. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/openllmetry_sdk/version.py +0 -0
  26. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/sdk/__init__.py +0 -0
  27. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/sdk/datasets.py +0 -0
  28. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/sdk/decorators.py +0 -0
  29. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/sdk/eval_control.py +0 -0
  30. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/sdk/evaluations.py +0 -0
  31. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/sdk/log.py +0 -0
  32. {lmnr-0.4.44 → lmnr-0.4.45}/src/lmnr/sdk/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lmnr
3
- Version: 0.4.44
3
+ Version: 0.4.45
4
4
  Summary: Python SDK for Laminar AI
5
5
  License: Apache-2.0
6
6
  Author: lmnr.ai
@@ -38,11 +38,9 @@ Provides-Extra: transformers
38
38
  Provides-Extra: vertexai
39
39
  Provides-Extra: watsonx
40
40
  Provides-Extra: weaviate
41
- Requires-Dist: aiohttp (>=3.0,<4.0)
42
- Requires-Dist: argparse (>=1.0,<2.0)
43
- Requires-Dist: backoff (>=2.0,<3.0)
44
- Requires-Dist: deprecated (>=1.0,<2.0)
45
- Requires-Dist: jinja2 (>=3.0,<4.0)
41
+ Requires-Dist: aiohttp (>=3.0)
42
+ Requires-Dist: argparse (>=1.0)
43
+ Requires-Dist: deprecated (>=1.0)
46
44
  Requires-Dist: opentelemetry-api (>=1.28.0)
47
45
  Requires-Dist: opentelemetry-exporter-otlp-proto-grpc (>=1.28.0)
48
46
  Requires-Dist: opentelemetry-exporter-otlp-proto-http (>=1.28.0)
@@ -77,11 +75,10 @@ Requires-Dist: opentelemetry-instrumentation-watsonx (>=0.33.12) ; extra == "all
77
75
  Requires-Dist: opentelemetry-instrumentation-weaviate (>=0.33.12) ; extra == "all" or extra == "weaviate"
78
76
  Requires-Dist: opentelemetry-sdk (>=1.28.0)
79
77
  Requires-Dist: opentelemetry-semantic-conventions-ai (==0.4.2)
80
- Requires-Dist: pydantic (>=2.7,<3.0)
81
- Requires-Dist: python-dotenv (>=1.0,<2.0)
82
- Requires-Dist: requests (>=2.0,<3.0)
83
- Requires-Dist: tenacity (>=8.0)
84
- Requires-Dist: tqdm (>=4.0,<5.0)
78
+ Requires-Dist: pydantic (>=2.7)
79
+ Requires-Dist: python-dotenv (>=1.0)
80
+ Requires-Dist: requests (>=2.0)
81
+ Requires-Dist: tqdm (>=4.0)
85
82
  Description-Content-Type: text/markdown
86
83
 
87
84
  # Laminar Python
@@ -6,7 +6,7 @@
6
6
 
7
7
  [project]
8
8
  name = "lmnr"
9
- version = "0.4.44"
9
+ version = "0.4.45"
10
10
  description = "Python SDK for Laminar AI"
11
11
  authors = [
12
12
  { name = "lmnr.ai", email = "founders@lmnr.ai" }
@@ -17,7 +17,7 @@ license = "Apache-2.0"
17
17
 
18
18
  [tool.poetry]
19
19
  name = "lmnr"
20
- version = "0.4.44"
20
+ version = "0.4.45"
21
21
  description = "Python SDK for Laminar AI"
22
22
  authors = ["lmnr.ai"]
23
23
  readme = "README.md"
@@ -25,10 +25,9 @@ license = "Apache-2.0"
25
25
 
26
26
  [tool.poetry.dependencies]
27
27
  python = ">=3.9,<4"
28
- pydantic = "~=2.7"
29
- requests = "~=2.0"
30
- python-dotenv = "~=1.0"
31
- backoff = "~=2.0"
28
+ pydantic = ">=2.7"
29
+ requests = ">=2.0"
30
+ python-dotenv = ">=1.0"
32
31
  opentelemetry-api = ">=1.28.0"
33
32
  opentelemetry-sdk = ">=1.28.0"
34
33
  opentelemetry-exporter-otlp-proto-http = ">=1.28.0"
@@ -38,12 +37,10 @@ opentelemetry-instrumentation-sqlalchemy = "^0.49b0"
38
37
  opentelemetry-instrumentation-urllib3 = "^0.49b0"
39
38
  opentelemetry-instrumentation-threading = "^0.49b0"
40
39
  opentelemetry-semantic-conventions-ai = "0.4.2"
41
- tenacity = ">=8.0"
42
- jinja2 = "~=3.0"
43
- deprecated = "~=1.0"
44
- tqdm = "~=4.0"
45
- argparse = "~=1.0"
46
- aiohttp = "~=3.0"
40
+ deprecated = ">=1.0"
41
+ tqdm = ">=4.0"
42
+ argparse = ">=1.0"
43
+ aiohttp = ">=3.0"
47
44
  opentelemetry-instrumentation-alephalpha = {version = ">=0.33.12", optional = true}
48
45
  opentelemetry-instrumentation-anthropic = {version = ">=0.33.12", optional = true}
49
46
  opentelemetry-instrumentation-bedrock = {version = ">=0.33.12", optional = true}
@@ -7,6 +7,7 @@ from .sdk.types import (
7
7
  NodeInput,
8
8
  PipelineRunError,
9
9
  PipelineRunResponse,
10
+ TracingLevel,
10
11
  )
11
12
  from .sdk.decorators import observe
12
13
  from .openllmetry_sdk import Instruments
@@ -12,6 +12,7 @@ ASSOCIATION_PROPERTIES = "lmnr.association.properties"
12
12
  SESSION_ID = "session_id"
13
13
  USER_ID = "user_id"
14
14
  TRACE_TYPE = "trace_type"
15
+ TRACING_LEVEL = "tracing_level"
15
16
 
16
17
 
17
18
  # exposed to the user, configurable
@@ -10,6 +10,7 @@ from lmnr.openllmetry_sdk.tracing.attributes import (
10
10
  ASSOCIATION_PROPERTIES,
11
11
  SPAN_INSTRUMENTATION_SOURCE,
12
12
  SPAN_PATH,
13
+ TRACING_LEVEL,
13
14
  )
14
15
  from lmnr.openllmetry_sdk.tracing.content_allow_list import ContentAllowList
15
16
  from lmnr.openllmetry_sdk.utils import is_notebook
@@ -224,6 +225,9 @@ def remove_association_properties(properties: dict) -> None:
224
225
 
225
226
  def _set_association_properties_attributes(span, properties: dict) -> None:
226
227
  for key, value in properties.items():
228
+ if key == TRACING_LEVEL:
229
+ span.set_attribute(f"lmnr.internal.{TRACING_LEVEL}", value)
230
+ continue
227
231
  span.set_attribute(f"{ASSOCIATION_PROPERTIES}.{key}", value)
228
232
 
229
233
 
@@ -59,6 +59,7 @@ from .types import (
59
59
  SemanticSearchRequest,
60
60
  SemanticSearchResponse,
61
61
  TraceType,
62
+ TracingLevel,
62
63
  )
63
64
 
64
65
 
@@ -558,6 +559,39 @@ class Laminar:
558
559
  if output is not None and span != trace.INVALID_SPAN:
559
560
  span.set_attribute(SPAN_OUTPUT, json_dumps(output))
560
561
 
562
+ @classmethod
563
+ @contextmanager
564
+ def set_tracing_level(self, level: TracingLevel):
565
+ """Set the tracing level for the current span and the context
566
+ (i.e. any children spans created from the current span in the current
567
+ thread).
568
+
569
+ Tracing level can be one of:
570
+ - `TracingLevel.ALL`: Enable tracing for the current span and all
571
+ children spans.
572
+ - `TracingLevel.META_ONLY`: Enable tracing for the current span and all
573
+ children spans, but only record metadata, e.g. tokens, costs.
574
+ - `TracingLevel.OFF`: Disable recording any spans.
575
+
576
+ Example:
577
+ ```python
578
+ from lmnr import Laminar, TracingLevel
579
+
580
+ with Laminar.set_tracing_level(TracingLevel.META_ONLY):
581
+ openai_client.chat.completions.create()
582
+ ```
583
+ """
584
+ if level == TracingLevel.ALL:
585
+ yield
586
+ else:
587
+ level = "meta_only" if level == TracingLevel.META_ONLY else "off"
588
+ update_association_properties({"tracing_level": level})
589
+ yield
590
+ try:
591
+ remove_association_properties({"tracing_level": level})
592
+ except Exception:
593
+ pass
594
+
561
595
  @classmethod
562
596
  def set_span_attributes(
563
597
  cls,
@@ -643,20 +677,6 @@ class Laminar:
643
677
  props.pop(k)
644
678
  set_association_properties(props)
645
679
 
646
- @classmethod
647
- def _set_trace_type(
648
- cls,
649
- trace_type: TraceType,
650
- ):
651
- """Set the trace_type for the current span and the context
652
- Args:
653
- trace_type (TraceType): Type of the trace
654
- """
655
- association_properties = {
656
- TRACE_TYPE: trace_type.value,
657
- }
658
- update_association_properties(association_properties)
659
-
660
680
  @classmethod
661
681
  def clear_session(cls):
662
682
  """Clear the session and user id from the context"""
@@ -732,6 +752,20 @@ class Laminar:
732
752
  "Content-Type": "application/json",
733
753
  }
734
754
 
755
+ @classmethod
756
+ def _set_trace_type(
757
+ cls,
758
+ trace_type: TraceType,
759
+ ):
760
+ """Set the trace_type for the current span and the context
761
+ Args:
762
+ trace_type (TraceType): Type of the trace
763
+ """
764
+ association_properties = {
765
+ TRACE_TYPE: trace_type.value,
766
+ }
767
+ update_association_properties(association_properties)
768
+
735
769
  @classmethod
736
770
  async def __run(
737
771
  cls,
@@ -203,3 +203,9 @@ class TraceType(Enum):
203
203
  class GetDatapointsResponse(pydantic.BaseModel):
204
204
  items: list[Datapoint]
205
205
  totalCount: int
206
+
207
+
208
+ class TracingLevel(Enum):
209
+ OFF = 0
210
+ META_ONLY = 1
211
+ ALL = 2
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes