lmnr 0.4.37__py3-none-any.whl → 0.4.39__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.
- lmnr/sdk/decorators.py +0 -8
- lmnr/sdk/laminar.py +2 -15
- {lmnr-0.4.37.dist-info → lmnr-0.4.39.dist-info}/METADATA +74 -53
- {lmnr-0.4.37.dist-info → lmnr-0.4.39.dist-info}/RECORD +7 -7
- {lmnr-0.4.37.dist-info → lmnr-0.4.39.dist-info}/LICENSE +0 -0
- {lmnr-0.4.37.dist-info → lmnr-0.4.39.dist-info}/WHEEL +0 -0
- {lmnr-0.4.37.dist-info → lmnr-0.4.39.dist-info}/entry_points.txt +0 -0
lmnr/sdk/decorators.py
CHANGED
@@ -20,7 +20,6 @@ R = TypeVar("R")
|
|
20
20
|
def observe(
|
21
21
|
*,
|
22
22
|
name: Optional[str] = None,
|
23
|
-
user_id: Optional[str] = None,
|
24
23
|
session_id: Optional[str] = None,
|
25
24
|
) -> Callable[[Callable[P, R]], Callable[P, R]]:
|
26
25
|
"""The main decorator entrypoint for Laminar. This is used to wrap
|
@@ -30,9 +29,6 @@ def observe(
|
|
30
29
|
name (Optional[str], optional): Name of the span. Function
|
31
30
|
name is used if not specified.
|
32
31
|
Defaults to None.
|
33
|
-
user_id (Optional[str], optional): User ID to associate
|
34
|
-
with the span and the following context.
|
35
|
-
Defaults to None.
|
36
32
|
session_id (Optional[str], optional): Session ID to associate with the
|
37
33
|
span and the following context. Defaults to None.
|
38
34
|
|
@@ -49,13 +45,9 @@ def observe(
|
|
49
45
|
if current_span != INVALID_SPAN:
|
50
46
|
if session_id is not None:
|
51
47
|
current_span.set_attribute(SESSION_ID, session_id)
|
52
|
-
if user_id is not None:
|
53
|
-
current_span.set_attribute(USER_ID, user_id)
|
54
48
|
association_properties = {}
|
55
49
|
if session_id is not None:
|
56
50
|
association_properties["session_id"] = session_id
|
57
|
-
if user_id is not None:
|
58
|
-
association_properties["user_id"] = user_id
|
59
51
|
update_association_properties(association_properties)
|
60
52
|
return (
|
61
53
|
aentity_method(name=name)(func)
|
lmnr/sdk/laminar.py
CHANGED
@@ -36,7 +36,6 @@ from lmnr.openllmetry_sdk.tracing.attributes import (
|
|
36
36
|
SPAN_OUTPUT,
|
37
37
|
SPAN_PATH,
|
38
38
|
TRACE_TYPE,
|
39
|
-
USER_ID,
|
40
39
|
)
|
41
40
|
from lmnr.openllmetry_sdk.tracing.tracing import (
|
42
41
|
get_span_path,
|
@@ -588,7 +587,6 @@ class Laminar:
|
|
588
587
|
def set_session(
|
589
588
|
cls,
|
590
589
|
session_id: Optional[str] = None,
|
591
|
-
user_id: Optional[str] = None,
|
592
590
|
):
|
593
591
|
"""Set the session and user id for the current span and the context
|
594
592
|
(i.e. any children spans created from the current span in the current
|
@@ -599,29 +597,18 @@ class Laminar:
|
|
599
597
|
Useful to debug and group long-running\
|
600
598
|
sessions/conversations.
|
601
599
|
Defaults to None.
|
602
|
-
user_id (Optional[str], optional). Deprecated.\
|
603
|
-
Use `Laminar.set_metadata` instead.\
|
604
|
-
Custom user id.\
|
605
|
-
Useful for grouping spans or traces by user.\
|
606
|
-
Defaults to None.
|
607
600
|
"""
|
608
601
|
association_properties = {}
|
609
602
|
if session_id is not None:
|
610
603
|
association_properties[SESSION_ID] = session_id
|
611
|
-
if user_id is not None:
|
612
|
-
cls.__logger.warning(
|
613
|
-
"User ID in set_session is deprecated and will be removed soon. "
|
614
|
-
"Please use `Laminar.set_metadata` instead."
|
615
|
-
)
|
616
|
-
association_properties["metadata." + USER_ID] = user_id
|
617
604
|
update_association_properties(association_properties)
|
618
605
|
|
619
606
|
@classmethod
|
620
|
-
def set_metadata(cls, metadata: dict[str,
|
607
|
+
def set_metadata(cls, metadata: dict[str, str]):
|
621
608
|
"""Set the metadata for the current trace.
|
622
609
|
|
623
610
|
Args:
|
624
|
-
metadata (dict[str,
|
611
|
+
metadata (dict[str, str]): Metadata to set for the trace. Willl be\
|
625
612
|
sent as attributes, so must be json serializable.
|
626
613
|
"""
|
627
614
|
props = {f"metadata.{k}": json_dumps(v) for k, v in metadata.items()}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: lmnr
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.39
|
4
4
|
Summary: Python SDK for Laminar AI
|
5
5
|
License: Apache-2.0
|
6
6
|
Author: lmnr.ai
|
@@ -12,6 +12,32 @@ Classifier: Programming Language :: Python :: 3.10
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.11
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
14
14
|
Classifier: Programming Language :: Python :: 3.13
|
15
|
+
Provides-Extra: alephalpha
|
16
|
+
Provides-Extra: all
|
17
|
+
Provides-Extra: anthropic
|
18
|
+
Provides-Extra: bedrock
|
19
|
+
Provides-Extra: chromadb
|
20
|
+
Provides-Extra: cohere
|
21
|
+
Provides-Extra: google-generativeai
|
22
|
+
Provides-Extra: groq
|
23
|
+
Provides-Extra: haystack
|
24
|
+
Provides-Extra: lancedb
|
25
|
+
Provides-Extra: langchain
|
26
|
+
Provides-Extra: llamaindex
|
27
|
+
Provides-Extra: marqo
|
28
|
+
Provides-Extra: milvus
|
29
|
+
Provides-Extra: mistralai
|
30
|
+
Provides-Extra: ollama
|
31
|
+
Provides-Extra: openai
|
32
|
+
Provides-Extra: pinecone
|
33
|
+
Provides-Extra: qdrant
|
34
|
+
Provides-Extra: replicate
|
35
|
+
Provides-Extra: sagemaker
|
36
|
+
Provides-Extra: together
|
37
|
+
Provides-Extra: transformers
|
38
|
+
Provides-Extra: vertexai
|
39
|
+
Provides-Extra: watsonx
|
40
|
+
Provides-Extra: weaviate
|
15
41
|
Requires-Dist: argparse (>=1.0,<2.0)
|
16
42
|
Requires-Dist: backoff (>=2.0,<3.0)
|
17
43
|
Requires-Dist: deprecated (>=1.0,<2.0)
|
@@ -19,35 +45,35 @@ Requires-Dist: jinja2 (>=3.0,<4.0)
|
|
19
45
|
Requires-Dist: opentelemetry-api (>=1.28.0)
|
20
46
|
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc (>=1.28.0)
|
21
47
|
Requires-Dist: opentelemetry-exporter-otlp-proto-http (>=1.28.0)
|
22
|
-
Requires-Dist: opentelemetry-instrumentation-alephalpha (>=0.33.
|
23
|
-
Requires-Dist: opentelemetry-instrumentation-anthropic (>=0.33.
|
24
|
-
Requires-Dist: opentelemetry-instrumentation-bedrock (>=0.33.
|
25
|
-
Requires-Dist: opentelemetry-instrumentation-chromadb (>=0.33.
|
26
|
-
Requires-Dist: opentelemetry-instrumentation-cohere (>=0.33.
|
27
|
-
Requires-Dist: opentelemetry-instrumentation-google-generativeai (>=0.33.
|
28
|
-
Requires-Dist: opentelemetry-instrumentation-groq (>=0.33.
|
29
|
-
Requires-Dist: opentelemetry-instrumentation-haystack (>=0.33.
|
30
|
-
Requires-Dist: opentelemetry-instrumentation-lancedb (>=0.33.
|
31
|
-
Requires-Dist: opentelemetry-instrumentation-langchain (>=0.33.
|
32
|
-
Requires-Dist: opentelemetry-instrumentation-llamaindex (>=0.33.
|
33
|
-
Requires-Dist: opentelemetry-instrumentation-marqo (>=0.33.
|
34
|
-
Requires-Dist: opentelemetry-instrumentation-milvus (>=0.33.
|
35
|
-
Requires-Dist: opentelemetry-instrumentation-mistralai (>=0.33.
|
36
|
-
Requires-Dist: opentelemetry-instrumentation-ollama (>=0.33.
|
37
|
-
Requires-Dist: opentelemetry-instrumentation-openai (>=0.33.
|
38
|
-
Requires-Dist: opentelemetry-instrumentation-pinecone (>=0.33.
|
39
|
-
Requires-Dist: opentelemetry-instrumentation-qdrant (>=0.33.
|
40
|
-
Requires-Dist: opentelemetry-instrumentation-replicate (>=0.33.
|
48
|
+
Requires-Dist: opentelemetry-instrumentation-alephalpha (>=0.33.12) ; extra == "all" or extra == "alephalpha"
|
49
|
+
Requires-Dist: opentelemetry-instrumentation-anthropic (>=0.33.12) ; extra == "all" or extra == "anthropic"
|
50
|
+
Requires-Dist: opentelemetry-instrumentation-bedrock (>=0.33.12) ; extra == "all" or extra == "bedrock"
|
51
|
+
Requires-Dist: opentelemetry-instrumentation-chromadb (>=0.33.12) ; extra == "all" or extra == "chromadb"
|
52
|
+
Requires-Dist: opentelemetry-instrumentation-cohere (>=0.33.12) ; extra == "all" or extra == "cohere"
|
53
|
+
Requires-Dist: opentelemetry-instrumentation-google-generativeai (>=0.33.12) ; extra == "all" or extra == "google-generativeai"
|
54
|
+
Requires-Dist: opentelemetry-instrumentation-groq (>=0.33.12) ; extra == "all" or extra == "groq"
|
55
|
+
Requires-Dist: opentelemetry-instrumentation-haystack (>=0.33.12) ; extra == "all" or extra == "haystack"
|
56
|
+
Requires-Dist: opentelemetry-instrumentation-lancedb (>=0.33.12) ; extra == "all" or extra == "lancedb"
|
57
|
+
Requires-Dist: opentelemetry-instrumentation-langchain (>=0.33.12) ; extra == "all" or extra == "langchain"
|
58
|
+
Requires-Dist: opentelemetry-instrumentation-llamaindex (>=0.33.12) ; extra == "all" or extra == "llamaindex"
|
59
|
+
Requires-Dist: opentelemetry-instrumentation-marqo (>=0.33.12) ; extra == "all" or extra == "marqo"
|
60
|
+
Requires-Dist: opentelemetry-instrumentation-milvus (>=0.33.12) ; extra == "all" or extra == "milvus"
|
61
|
+
Requires-Dist: opentelemetry-instrumentation-mistralai (>=0.33.12) ; extra == "all" or extra == "mistralai"
|
62
|
+
Requires-Dist: opentelemetry-instrumentation-ollama (>=0.33.12) ; extra == "all" or extra == "ollama"
|
63
|
+
Requires-Dist: opentelemetry-instrumentation-openai (>=0.33.12) ; extra == "all" or extra == "openai"
|
64
|
+
Requires-Dist: opentelemetry-instrumentation-pinecone (>=0.33.12) ; extra == "all" or extra == "pinecone"
|
65
|
+
Requires-Dist: opentelemetry-instrumentation-qdrant (>=0.33.12) ; extra == "all" or extra == "qdrant"
|
66
|
+
Requires-Dist: opentelemetry-instrumentation-replicate (>=0.33.12) ; extra == "all" or extra == "replicate"
|
41
67
|
Requires-Dist: opentelemetry-instrumentation-requests (>=0.49b0,<0.50)
|
42
|
-
Requires-Dist: opentelemetry-instrumentation-sagemaker (>=0.33.
|
68
|
+
Requires-Dist: opentelemetry-instrumentation-sagemaker (>=0.33.12) ; extra == "all" or extra == "sagemaker"
|
43
69
|
Requires-Dist: opentelemetry-instrumentation-sqlalchemy (>=0.49b0,<0.50)
|
44
70
|
Requires-Dist: opentelemetry-instrumentation-threading (>=0.49b0,<0.50)
|
45
|
-
Requires-Dist: opentelemetry-instrumentation-together (>=0.33.
|
46
|
-
Requires-Dist: opentelemetry-instrumentation-transformers (>=0.33.
|
71
|
+
Requires-Dist: opentelemetry-instrumentation-together (>=0.33.12) ; extra == "all" or extra == "together"
|
72
|
+
Requires-Dist: opentelemetry-instrumentation-transformers (>=0.33.12) ; extra == "all" or extra == "transformers"
|
47
73
|
Requires-Dist: opentelemetry-instrumentation-urllib3 (>=0.49b0,<0.50)
|
48
|
-
Requires-Dist: opentelemetry-instrumentation-vertexai (>=0.33.
|
49
|
-
Requires-Dist: opentelemetry-instrumentation-watsonx (>=0.33.
|
50
|
-
Requires-Dist: opentelemetry-instrumentation-weaviate (>=0.33.
|
74
|
+
Requires-Dist: opentelemetry-instrumentation-vertexai (>=0.33.12) ; extra == "all" or extra == "vertexai"
|
75
|
+
Requires-Dist: opentelemetry-instrumentation-watsonx (>=0.33.12) ; extra == "all" or extra == "watsonx"
|
76
|
+
Requires-Dist: opentelemetry-instrumentation-weaviate (>=0.33.12) ; extra == "all" or extra == "weaviate"
|
51
77
|
Requires-Dist: opentelemetry-sdk (>=1.28.0)
|
52
78
|
Requires-Dist: opentelemetry-semantic-conventions-ai (==0.4.2)
|
53
79
|
Requires-Dist: pydantic (>=2.7,<3.0)
|
@@ -72,23 +98,28 @@ Check our [open-source repo](https://github.com/lmnr-ai/lmnr) and don't forget t
|
|
72
98
|
|
73
99
|
## Quickstart
|
74
100
|
|
75
|
-
First, install the package
|
101
|
+
First, install the package, specifying the instrumentations you want to use.
|
102
|
+
|
103
|
+
For example, to install the package with OpenAI and Anthropic instrumentations:
|
76
104
|
|
77
105
|
```sh
|
78
|
-
pip install lmnr
|
106
|
+
pip install 'lmnr[anthropic,openai]'
|
79
107
|
```
|
80
108
|
|
81
|
-
|
109
|
+
To install all possible instrumentations, use the following command:
|
110
|
+
|
111
|
+
```sh
|
112
|
+
pip install 'lmnr[all]'
|
113
|
+
```
|
114
|
+
|
115
|
+
Initialize Laminar in your code:
|
82
116
|
|
83
117
|
```python
|
84
|
-
from lmnr import Laminar
|
118
|
+
from lmnr import Laminar
|
85
119
|
|
86
|
-
|
120
|
+
Laminar.initialize(project_api_key="<PROJECT_API_KEY>")
|
87
121
|
```
|
88
122
|
|
89
|
-
This will automatically instrument most of the LLM, Vector DB, and related
|
90
|
-
calls with OpenTelemetry-compatible instrumentation.
|
91
|
-
|
92
123
|
Note that you need to only initialize Laminar once in your application.
|
93
124
|
|
94
125
|
## Instrumentation
|
@@ -101,9 +132,9 @@ This can be useful if you want to trace a request handler or a function which co
|
|
101
132
|
```python
|
102
133
|
import os
|
103
134
|
from openai import OpenAI
|
104
|
-
from lmnr import Laminar
|
135
|
+
from lmnr import Laminar
|
105
136
|
|
106
|
-
|
137
|
+
Laminar.initialize(project_api_key=os.environ["LMNR_PROJECT_API_KEY"])
|
107
138
|
|
108
139
|
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
|
109
140
|
|
@@ -126,9 +157,7 @@ def poem_writer(topic: str):
|
|
126
157
|
@observe()
|
127
158
|
def generate_poems():
|
128
159
|
poem1 = poem_writer(topic="laminar flow")
|
129
|
-
L.event("is_poem_generated", True)
|
130
160
|
poem2 = poem_writer(topic="turbulence")
|
131
|
-
L.event("is_poem_generated", True)
|
132
161
|
poems = f"{poem1}\n\n---\n\n{poem2}"
|
133
162
|
return poems
|
134
163
|
```
|
@@ -137,18 +166,10 @@ Also, you can use `Laminar.start_as_current_span` if you want to record a chunk
|
|
137
166
|
|
138
167
|
```python
|
139
168
|
def handle_user_request(topic: str):
|
140
|
-
with
|
141
|
-
...
|
142
|
-
|
169
|
+
with Laminar.start_as_current_span(name="poem_writer", input=topic):
|
143
170
|
poem = poem_writer(topic=topic)
|
144
|
-
|
145
|
-
...
|
146
|
-
|
147
|
-
# while within the span, you can attach laminar events to it
|
148
|
-
L.event("is_poem_generated", True)
|
149
|
-
|
150
171
|
# Use set_span_output to record the output of the span
|
151
|
-
|
172
|
+
Laminar.set_span_output(poem)
|
152
173
|
```
|
153
174
|
|
154
175
|
### Automatic instrumentation
|
@@ -163,9 +184,9 @@ calls with OpenTelemetry-compatible instrumentation, then pass the appropriate i
|
|
163
184
|
For example, if you want to only instrument OpenAI and Anthropic, then do the following:
|
164
185
|
|
165
186
|
```python
|
166
|
-
from lmnr import Laminar
|
187
|
+
from lmnr import Laminar, Instruments
|
167
188
|
|
168
|
-
|
189
|
+
Laminar.initialize(project_api_key=os.environ["LMNR_PROJECT_API_KEY"], instruments={Instruments.OPENAI, Instruments.ANTHROPIC})
|
169
190
|
```
|
170
191
|
|
171
192
|
If you want to fully disable any kind of autoinstrumentation, pass an empty set as `instruments=set()` to `.initialize()`.
|
@@ -246,11 +267,11 @@ Once your pipeline target is set, you can call it from Python in just a few line
|
|
246
267
|
Example use:
|
247
268
|
|
248
269
|
```python
|
249
|
-
from lmnr import Laminar
|
270
|
+
from lmnr import Laminar
|
250
271
|
|
251
|
-
|
272
|
+
Laminar.initialize('<YOUR_PROJECT_API_KEY>', instruments=set())
|
252
273
|
|
253
|
-
result =
|
274
|
+
result = Laminar.run(
|
254
275
|
pipeline = 'my_pipeline_name',
|
255
276
|
inputs = {'input_node_name': 'some_value'},
|
256
277
|
# all environment variables
|
@@ -19,14 +19,14 @@ lmnr/openllmetry_sdk/utils/package_check.py,sha256=Ki74WZME-ASF0fx7RXSIMsULGYUzI
|
|
19
19
|
lmnr/openllmetry_sdk/version.py,sha256=OlatFEFA4ttqSSIiV8jdE-sq3KG5zu2hnC4B4mzWF3s,23
|
20
20
|
lmnr/sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
21
21
|
lmnr/sdk/datasets.py,sha256=w8U9E6fvetAo65Cb2CbYzlfhY8CfXAR-VysrakG6-4I,1591
|
22
|
-
lmnr/sdk/decorators.py,sha256=
|
22
|
+
lmnr/sdk/decorators.py,sha256=6F2Z9ElNe_-9Y3PxRmKK5LKCHWfzTgMSNR3RFLAsg6c,1865
|
23
23
|
lmnr/sdk/evaluations.py,sha256=rz92RKam5bWTj-w-c2ZTdsK6Bl7KSxW5UarBjG472Mc,16268
|
24
|
-
lmnr/sdk/laminar.py,sha256=
|
24
|
+
lmnr/sdk/laminar.py,sha256=0wZE0gDq8eEx4zOTNuLuD--tY9DNSBGldo8158cfxmY,26810
|
25
25
|
lmnr/sdk/log.py,sha256=cZBeUoSK39LMEV-X4-eEhTWOciULRfHaKfRK8YqIM8I,1532
|
26
26
|
lmnr/sdk/types.py,sha256=qGD1tkGszd-_sZJaZ_Zx9U_CdUYzoDkUeN2g-o48Gls,5588
|
27
27
|
lmnr/sdk/utils.py,sha256=Uk8y15x-sd5tP2ERONahElLDJVEy_3dA_1_5g9A6auY,3358
|
28
|
-
lmnr-0.4.
|
29
|
-
lmnr-0.4.
|
30
|
-
lmnr-0.4.
|
31
|
-
lmnr-0.4.
|
32
|
-
lmnr-0.4.
|
28
|
+
lmnr-0.4.39.dist-info/LICENSE,sha256=67b_wJHVV1CBaWkrKFWU1wyqTPSdzH77Ls-59631COg,10411
|
29
|
+
lmnr-0.4.39.dist-info/METADATA,sha256=gmRAMfYV6a9AaafaoM2cIt0Gcsi0IevZGUltuSTjbOs,11938
|
30
|
+
lmnr-0.4.39.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
31
|
+
lmnr-0.4.39.dist-info/entry_points.txt,sha256=K1jE20ww4jzHNZLnsfWBvU3YKDGBgbOiYG5Y7ivQcq4,37
|
32
|
+
lmnr-0.4.39.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|