langtrace-python-sdk 2.3.16__py3-none-any.whl → 2.3.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.
- langtrace_python_sdk/instrumentation/anthropic/patch.py +1 -1
- langtrace_python_sdk/langtrace.py +25 -63
- langtrace_python_sdk/types/__init__.py +14 -5
- langtrace_python_sdk/utils/__init__.py +42 -1
- langtrace_python_sdk/version.py +1 -1
- {langtrace_python_sdk-2.3.16.dist-info → langtrace_python_sdk-2.3.18.dist-info}/METADATA +1 -1
- {langtrace_python_sdk-2.3.16.dist-info → langtrace_python_sdk-2.3.18.dist-info}/RECORD +10 -10
- {langtrace_python_sdk-2.3.16.dist-info → langtrace_python_sdk-2.3.18.dist-info}/WHEEL +0 -0
- {langtrace_python_sdk-2.3.16.dist-info → langtrace_python_sdk-2.3.18.dist-info}/entry_points.txt +0 -0
- {langtrace_python_sdk-2.3.16.dist-info → langtrace_python_sdk-2.3.18.dist-info}/licenses/LICENSE +0 -0
|
@@ -112,7 +112,7 @@ def messages_create(version: str, tracer: Tracer) -> Callable[..., Any]:
|
|
|
112
112
|
if typ == "text":
|
|
113
113
|
content = result.content[0].text
|
|
114
114
|
set_event_completion(
|
|
115
|
-
span, [{"type": typ, role: role, content: content}]
|
|
115
|
+
span, [{"type": typ, "role": role, "content": content}]
|
|
116
116
|
)
|
|
117
117
|
|
|
118
118
|
if (
|
|
@@ -16,8 +16,7 @@ limitations under the License.
|
|
|
16
16
|
|
|
17
17
|
import os
|
|
18
18
|
import sys
|
|
19
|
-
from typing import Optional
|
|
20
|
-
import importlib.util
|
|
19
|
+
from typing import Any, Optional
|
|
21
20
|
from colorama import Fore
|
|
22
21
|
from langtrace_python_sdk.constants import LANGTRACE_SDK_NAME, SENTRY_DSN
|
|
23
22
|
from opentelemetry import trace
|
|
@@ -62,7 +61,12 @@ from langtrace_python_sdk.types import (
|
|
|
62
61
|
InstrumentationMethods,
|
|
63
62
|
InstrumentationType,
|
|
64
63
|
)
|
|
65
|
-
from langtrace_python_sdk.utils import
|
|
64
|
+
from langtrace_python_sdk.utils import (
|
|
65
|
+
check_if_sdk_is_outdated,
|
|
66
|
+
get_sdk_version,
|
|
67
|
+
is_package_installed,
|
|
68
|
+
validate_instrumentations,
|
|
69
|
+
)
|
|
66
70
|
from langtrace_python_sdk.utils.langtrace_sampler import LangtraceSampler
|
|
67
71
|
import sentry_sdk
|
|
68
72
|
|
|
@@ -193,10 +197,10 @@ def init(
|
|
|
193
197
|
|
|
194
198
|
def init_instrumentations(
|
|
195
199
|
disable_instrumentations: Optional[DisableInstrumentations],
|
|
196
|
-
all_instrumentations: dict
|
|
200
|
+
all_instrumentations: dict,
|
|
197
201
|
):
|
|
198
202
|
if disable_instrumentations is None:
|
|
199
|
-
for
|
|
203
|
+
for name, v in all_instrumentations.items():
|
|
200
204
|
if is_package_installed(name):
|
|
201
205
|
v.instrument()
|
|
202
206
|
|
|
@@ -205,61 +209,19 @@ def init_instrumentations(
|
|
|
205
209
|
validate_instrumentations(disable_instrumentations)
|
|
206
210
|
|
|
207
211
|
for key in disable_instrumentations:
|
|
208
|
-
for
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
for _, v in filtered_dict.items():
|
|
225
|
-
v.instrument()
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
def validate_instrumentations(disable_instrumentations):
|
|
229
|
-
if disable_instrumentations is not None:
|
|
230
|
-
for key, value in disable_instrumentations.items():
|
|
231
|
-
if isinstance(value, str):
|
|
232
|
-
# Convert single string to list of enum values
|
|
233
|
-
disable_instrumentations[key] = [InstrumentationType.from_string(value)]
|
|
234
|
-
elif isinstance(value, list):
|
|
235
|
-
# Convert list of strings to list of enum values
|
|
236
|
-
disable_instrumentations[key] = [
|
|
237
|
-
(
|
|
238
|
-
InstrumentationType.from_string(item)
|
|
239
|
-
if isinstance(item, str)
|
|
240
|
-
else item
|
|
241
|
-
)
|
|
242
|
-
for item in value
|
|
243
|
-
]
|
|
244
|
-
# Validate all items are of enum type
|
|
245
|
-
if not all(
|
|
246
|
-
isinstance(item, InstrumentationType)
|
|
247
|
-
for item in disable_instrumentations[key]
|
|
248
|
-
):
|
|
249
|
-
raise TypeError(
|
|
250
|
-
f"All items in {key} must be of type InstrumentationType"
|
|
251
|
-
)
|
|
252
|
-
if (
|
|
253
|
-
disable_instrumentations.get("all_except") is not None
|
|
254
|
-
and disable_instrumentations.get("only") is not None
|
|
255
|
-
):
|
|
256
|
-
raise ValueError(
|
|
257
|
-
"Cannot specify both only and all_except in disable_instrumentations"
|
|
258
|
-
)
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
def is_package_installed(package_name):
|
|
262
|
-
import pkg_resources
|
|
263
|
-
|
|
264
|
-
installed_packages = {p.key for p in pkg_resources.working_set}
|
|
265
|
-
return package_name in installed_packages
|
|
212
|
+
vendors = [k.value for k in disable_instrumentations[key]]
|
|
213
|
+
|
|
214
|
+
key = next(iter(disable_instrumentations))
|
|
215
|
+
filtered_dict = {}
|
|
216
|
+
if key == "all_except":
|
|
217
|
+
filtered_dict = {
|
|
218
|
+
k: v for k, v in all_instrumentations.items() if k in vendors
|
|
219
|
+
}
|
|
220
|
+
elif key == "only":
|
|
221
|
+
filtered_dict = {
|
|
222
|
+
k: v for k, v in all_instrumentations.items() if k not in vendors
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
for name, v in filtered_dict.items():
|
|
226
|
+
if is_package_installed(name):
|
|
227
|
+
v.instrument()
|
|
@@ -8,16 +8,22 @@ class InstrumentationType(Enum):
|
|
|
8
8
|
ANTHROPIC = "anthropic"
|
|
9
9
|
GROQ = "groq"
|
|
10
10
|
MISTRAL = "mistral"
|
|
11
|
-
PINECONE = "pinecone"
|
|
12
|
-
LLAMAINDEX = "
|
|
11
|
+
PINECONE = "pinecone-client"
|
|
12
|
+
LLAMAINDEX = "llama-index"
|
|
13
13
|
CHROMADB = "chromadb"
|
|
14
14
|
QDRANT = "qdrant"
|
|
15
15
|
LANGCHAIN = "langchain"
|
|
16
|
-
LANGCHAIN_CORE = "
|
|
17
|
-
LANGCHAIN_COMMUNITY = "
|
|
16
|
+
LANGCHAIN_CORE = "langchain-core"
|
|
17
|
+
LANGCHAIN_COMMUNITY = "langchain-community"
|
|
18
18
|
LANGGRAPH = "langgraph"
|
|
19
19
|
WEAVIATE = "weaviate"
|
|
20
20
|
OLLAMA = "ollama"
|
|
21
|
+
AUTOGEN = "autogen"
|
|
22
|
+
DSPY = "dspy-ai"
|
|
23
|
+
CREWAI = "crewai"
|
|
24
|
+
GEMINI = "google-generativeai"
|
|
25
|
+
VERTEXAI = "google-cloud-aiplatform"
|
|
26
|
+
MISTRALAI = "mistralai"
|
|
21
27
|
|
|
22
28
|
@staticmethod
|
|
23
29
|
def from_string(value: str):
|
|
@@ -112,7 +118,10 @@ class InstrumentationMethods(TypedDict):
|
|
|
112
118
|
cohere: List[VendorMethods.CohereMethods]
|
|
113
119
|
weaviate: List[str]
|
|
114
120
|
|
|
121
|
+
|
|
115
122
|
_T = TypeVar("_T")
|
|
123
|
+
|
|
124
|
+
|
|
116
125
|
class NotGiven:
|
|
117
126
|
"""
|
|
118
127
|
A sentinel singleton class used to distinguish omitted keyword arguments
|
|
@@ -139,4 +148,4 @@ class NotGiven:
|
|
|
139
148
|
|
|
140
149
|
|
|
141
150
|
NotGivenOr = Union[_T, NotGiven]
|
|
142
|
-
NOT_GIVEN = NotGiven()
|
|
151
|
+
NOT_GIVEN = NotGiven()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from langtrace_python_sdk.types import NOT_GIVEN
|
|
1
|
+
from langtrace_python_sdk.types import NOT_GIVEN, InstrumentationType
|
|
2
2
|
from .sdk_version_checker import SDKVersionChecker
|
|
3
3
|
from opentelemetry.trace import Span
|
|
4
4
|
from langtrace.trace_attributes import SpanAttributes
|
|
@@ -49,3 +49,44 @@ def check_if_sdk_is_outdated():
|
|
|
49
49
|
|
|
50
50
|
def get_sdk_version():
|
|
51
51
|
return SDKVersionChecker().get_sdk_version()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def validate_instrumentations(disable_instrumentations):
|
|
55
|
+
if disable_instrumentations is not None:
|
|
56
|
+
if (
|
|
57
|
+
disable_instrumentations.get("all_except") is not None
|
|
58
|
+
and disable_instrumentations.get("only") is not None
|
|
59
|
+
):
|
|
60
|
+
raise ValueError(
|
|
61
|
+
"Cannot specify both only and all_except in disable_instrumentations"
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
for key, value in disable_instrumentations.items():
|
|
65
|
+
if isinstance(value, str):
|
|
66
|
+
# Convert single string to list of enum values
|
|
67
|
+
disable_instrumentations[key] = [InstrumentationType.from_string(value)]
|
|
68
|
+
elif isinstance(value, list):
|
|
69
|
+
# Convert list of strings to list of enum values
|
|
70
|
+
disable_instrumentations[key] = [
|
|
71
|
+
(
|
|
72
|
+
InstrumentationType.from_string(item)
|
|
73
|
+
if isinstance(item, str)
|
|
74
|
+
else item
|
|
75
|
+
)
|
|
76
|
+
for item in value
|
|
77
|
+
]
|
|
78
|
+
# Validate all items are of enum type
|
|
79
|
+
if not all(
|
|
80
|
+
isinstance(item, InstrumentationType)
|
|
81
|
+
for item in disable_instrumentations[key]
|
|
82
|
+
):
|
|
83
|
+
raise TypeError(
|
|
84
|
+
f"All items in {key} must be of type InstrumentationType"
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def is_package_installed(package_name):
|
|
89
|
+
import pkg_resources
|
|
90
|
+
|
|
91
|
+
installed_packages = {p.key for p in pkg_resources.working_set}
|
|
92
|
+
return package_name in installed_packages
|
langtrace_python_sdk/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "2.3.
|
|
1
|
+
__version__ = "2.3.18"
|
|
@@ -91,8 +91,8 @@ examples/vertexai_example/main.py,sha256=gndId5X5ksD-ycxnAWMdEqIDbLc3kz5Vt8vm4YP
|
|
|
91
91
|
examples/weaviate_example/__init__.py,sha256=8JMDBsRSEV10HfTd-YC7xb4txBjD3la56snk-Bbg2Kw,618
|
|
92
92
|
examples/weaviate_example/query_text.py,sha256=wPHQTc_58kPoKTZMygVjTj-2ZcdrIuaausJfMxNQnQc,127162
|
|
93
93
|
langtrace_python_sdk/__init__.py,sha256=VZM6i71NR7pBQK6XvJWRelknuTYUhqwqE7PlicKa5Wg,1166
|
|
94
|
-
langtrace_python_sdk/langtrace.py,sha256=
|
|
95
|
-
langtrace_python_sdk/version.py,sha256=
|
|
94
|
+
langtrace_python_sdk/langtrace.py,sha256=sNCOHq5dBsNAHkNLB9VsR-FgbnrQ_2Tjo7jiyR8svgk,8218
|
|
95
|
+
langtrace_python_sdk/version.py,sha256=mD-SDEtLNvyI2ufgzrAVc4SMA1MwfclBcYr9hOIt7Qo,23
|
|
96
96
|
langtrace_python_sdk/constants/__init__.py,sha256=3CNYkWMdd1DrkGqzLUgNZXjdAlM6UFMlf_F-odAToyc,146
|
|
97
97
|
langtrace_python_sdk/constants/exporter/langtrace_exporter.py,sha256=5MNjnAOg-4am78J3gVMH6FSwq5N8TOj72ugkhsw4vi0,46
|
|
98
98
|
langtrace_python_sdk/constants/instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -116,7 +116,7 @@ langtrace_python_sdk/extensions/langtrace_filesystem.py,sha256=34fZutG28EJ66l67O
|
|
|
116
116
|
langtrace_python_sdk/instrumentation/__init__.py,sha256=2ZSUFvF1Lv15PQvPGk8a_RiukjFKWOM5esDot5ZOkbo,1622
|
|
117
117
|
langtrace_python_sdk/instrumentation/anthropic/__init__.py,sha256=donrurJAGYlxrSRA3BIf76jGeUcAx9Tq8CVpah68S0Y,101
|
|
118
118
|
langtrace_python_sdk/instrumentation/anthropic/instrumentation.py,sha256=ndXdruI0BG7n75rsuEpKjfzePxrZxg40gZ39ONmD_v4,1845
|
|
119
|
-
langtrace_python_sdk/instrumentation/anthropic/patch.py,sha256=
|
|
119
|
+
langtrace_python_sdk/instrumentation/anthropic/patch.py,sha256=xVfWvULInOx_1dlC0phJsetDpN5cg8Dmma9hVlUHpSY,5234
|
|
120
120
|
langtrace_python_sdk/instrumentation/anthropic/types.py,sha256=WdeXe2tkjAisMLK38STKwVe7MJS5SLoETJ_aKhA_-UU,2463
|
|
121
121
|
langtrace_python_sdk/instrumentation/autogen/__init__.py,sha256=unDhpqWQIdHFw24lRsRu1Mm1NCZxZgyBrPRZrAJL3Lo,90
|
|
122
122
|
langtrace_python_sdk/instrumentation/autogen/instrumentation.py,sha256=0aUPPRtFkGBB2C7PYR3Myt8JHgze5vs93iCMqj2QN0E,1518
|
|
@@ -179,8 +179,8 @@ langtrace_python_sdk/instrumentation/vertexai/patch.py,sha256=vPxwuSKgA3cUtelgot
|
|
|
179
179
|
langtrace_python_sdk/instrumentation/weaviate/__init__.py,sha256=Mc-Je6evPo-kKQzerTG7bd1XO5JOh4YGTE3wBxaUBwg,99
|
|
180
180
|
langtrace_python_sdk/instrumentation/weaviate/instrumentation.py,sha256=bzPwtoQD0X6beLYXe6ZL7XRkyRkqdiqKiGc4gOlCQdU,2295
|
|
181
181
|
langtrace_python_sdk/instrumentation/weaviate/patch.py,sha256=aWLDbNGz35V6XQUv4lkMD0O689suqh6KdTa33VDtUkE,6905
|
|
182
|
-
langtrace_python_sdk/types/__init__.py,sha256=
|
|
183
|
-
langtrace_python_sdk/utils/__init__.py,sha256=
|
|
182
|
+
langtrace_python_sdk/types/__init__.py,sha256=VnfLV5pVHIB9VRIpEwIDQjWSPEAqQKnq6VNbqsm9W3Q,4287
|
|
183
|
+
langtrace_python_sdk/utils/__init__.py,sha256=O-Ra9IDd1MnxihdQUC8HW_wYFhk7KbTCK2BIl02yacQ,2935
|
|
184
184
|
langtrace_python_sdk/utils/langtrace_sampler.py,sha256=BupNndHbU9IL_wGleKetz8FdcveqHMBVz1bfKTTW80w,1753
|
|
185
185
|
langtrace_python_sdk/utils/llm.py,sha256=Hm3mr1iuk1dC-dGnBymDS6PEdOO5vaoPQzCtTeOqUQs,14970
|
|
186
186
|
langtrace_python_sdk/utils/misc.py,sha256=LaQr5LOmZMiuwVdjYh7aIu6o2C_Xb1wgpQGNOVmRzfE,1918
|
|
@@ -231,8 +231,8 @@ tests/pinecone/cassettes/test_query.yaml,sha256=b5v9G3ssUy00oG63PlFUR3JErF2Js-5A
|
|
|
231
231
|
tests/pinecone/cassettes/test_upsert.yaml,sha256=neWmQ1v3d03V8WoLl8FoFeeCYImb8pxlJBWnFd_lITU,38607
|
|
232
232
|
tests/qdrant/conftest.py,sha256=9n0uHxxIjWk9fbYc4bx-uP8lSAgLBVx-cV9UjnsyCHM,381
|
|
233
233
|
tests/qdrant/test_qdrant.py,sha256=pzjAjVY2kmsmGfrI2Gs2xrolfuaNHz7l1fqGQCjp5_o,3353
|
|
234
|
-
langtrace_python_sdk-2.3.
|
|
235
|
-
langtrace_python_sdk-2.3.
|
|
236
|
-
langtrace_python_sdk-2.3.
|
|
237
|
-
langtrace_python_sdk-2.3.
|
|
238
|
-
langtrace_python_sdk-2.3.
|
|
234
|
+
langtrace_python_sdk-2.3.18.dist-info/METADATA,sha256=VJScOd2S8TQoAooEiqHlsm7o6IMayM3z7f2-dUOEv9E,15380
|
|
235
|
+
langtrace_python_sdk-2.3.18.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
236
|
+
langtrace_python_sdk-2.3.18.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
|
|
237
|
+
langtrace_python_sdk-2.3.18.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
238
|
+
langtrace_python_sdk-2.3.18.dist-info/RECORD,,
|
|
File without changes
|
{langtrace_python_sdk-2.3.16.dist-info → langtrace_python_sdk-2.3.18.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.3.16.dist-info → langtrace_python_sdk-2.3.18.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|