langtrace-python-sdk 2.2.24__py3-none-any.whl → 2.2.25__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.
- examples/weaviate_example/query_text.py +12 -6
- langtrace_python_sdk/instrumentation/weaviate/instrumentation.py +1 -1
- langtrace_python_sdk/instrumentation/weaviate/patch.py +22 -7
- langtrace_python_sdk/version.py +1 -1
- {langtrace_python_sdk-2.2.24.dist-info → langtrace_python_sdk-2.2.25.dist-info}/METADATA +2 -2
- {langtrace_python_sdk-2.2.24.dist-info → langtrace_python_sdk-2.2.25.dist-info}/RECORD +9 -9
- {langtrace_python_sdk-2.2.24.dist-info → langtrace_python_sdk-2.2.25.dist-info}/WHEEL +0 -0
- {langtrace_python_sdk-2.2.24.dist-info → langtrace_python_sdk-2.2.25.dist-info}/entry_points.txt +0 -0
- {langtrace_python_sdk-2.2.24.dist-info → langtrace_python_sdk-2.2.25.dist-info}/licenses/LICENSE +0 -0
|
@@ -15,13 +15,14 @@ from pathlib import Path
|
|
|
15
15
|
import requests
|
|
16
16
|
import weaviate
|
|
17
17
|
import weaviate.classes as wvc
|
|
18
|
+
import weaviate.classes.config as wc
|
|
19
|
+
from dotenv import load_dotenv
|
|
18
20
|
from weaviate.classes.aggregate import GroupByAggregate
|
|
19
21
|
from weaviate.classes.query import Filter, HybridFusion, MetadataQuery
|
|
20
22
|
from weaviate.collections.classes.grpc import Move
|
|
21
23
|
|
|
22
24
|
import langtrace_python_sdk.langtrace as langtrace
|
|
23
25
|
from langtrace_python_sdk import with_langtrace_root_span
|
|
24
|
-
from dotenv import load_dotenv
|
|
25
26
|
|
|
26
27
|
load_dotenv()
|
|
27
28
|
# Set these environment variables
|
|
@@ -44,11 +45,16 @@ def create():
|
|
|
44
45
|
if not client.collections.get("Question"):
|
|
45
46
|
questions = client.collections.create(
|
|
46
47
|
name="Question",
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
properties=[
|
|
49
|
+
wc.Property(name="answer", data_type=wc.DataType.TEXT),
|
|
50
|
+
wc.Property(name="question", data_type=wc.DataType.TEXT),
|
|
51
|
+
wc.Property(name="category", data_type=wc.DataType.TEXT),
|
|
52
|
+
],
|
|
53
|
+
# Define the vectorizer module
|
|
54
|
+
vectorizer_config=wc.Configure.Vectorizer.text2vec_openai(),
|
|
55
|
+
# Define the generative module
|
|
56
|
+
generative_config=wc.Configure.Generative.openai(),
|
|
57
|
+
)
|
|
52
58
|
|
|
53
59
|
|
|
54
60
|
@with_langtrace_root_span("insert")
|
|
@@ -37,7 +37,7 @@ class WeaviateInstrumentation(BaseInstrumentor):
|
|
|
37
37
|
"""
|
|
38
38
|
|
|
39
39
|
def instrumentation_dependencies(self) -> Collection[str]:
|
|
40
|
-
return ["weaviate-client >= 4.6.1", "trace-attributes >=
|
|
40
|
+
return ["weaviate-client >= 4.6.1", "trace-attributes >= 7.0.3"]
|
|
41
41
|
|
|
42
42
|
def _instrument(self, **kwargs):
|
|
43
43
|
tracer_provider = kwargs.get("tracer_provider")
|
|
@@ -16,21 +16,21 @@ limitations under the License.
|
|
|
16
16
|
|
|
17
17
|
import json
|
|
18
18
|
|
|
19
|
+
from importlib_metadata import version as v
|
|
19
20
|
from langtrace.trace_attributes import DatabaseSpanAttributes
|
|
20
|
-
from langtrace_python_sdk.utils.llm import get_span_name
|
|
21
21
|
from opentelemetry import baggage, trace
|
|
22
22
|
from opentelemetry.trace import SpanKind
|
|
23
|
-
from opentelemetry.trace.status import Status, StatusCode
|
|
24
23
|
from opentelemetry.trace.propagation import set_span_in_context
|
|
24
|
+
from opentelemetry.trace.status import Status, StatusCode
|
|
25
|
+
|
|
26
|
+
from langtrace_python_sdk.constants import LANGTRACE_SDK_NAME
|
|
25
27
|
from langtrace_python_sdk.constants.instrumentation.common import (
|
|
26
28
|
LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY,
|
|
27
29
|
SERVICE_PROVIDERS,
|
|
28
30
|
)
|
|
29
31
|
from langtrace_python_sdk.constants.instrumentation.weaviate import APIS
|
|
32
|
+
from langtrace_python_sdk.utils.llm import get_span_name
|
|
30
33
|
from langtrace_python_sdk.utils.misc import extract_input_params, to_iso_format
|
|
31
|
-
from importlib_metadata import version as v
|
|
32
|
-
|
|
33
|
-
from langtrace_python_sdk.constants import LANGTRACE_SDK_NAME
|
|
34
34
|
|
|
35
35
|
# Predefined metadata response attributes
|
|
36
36
|
METADATA_ATTRIBUTES = [
|
|
@@ -45,6 +45,22 @@ METADATA_ATTRIBUTES = [
|
|
|
45
45
|
]
|
|
46
46
|
|
|
47
47
|
|
|
48
|
+
def extract_inputs(args, kwargs):
|
|
49
|
+
extracted_params = {}
|
|
50
|
+
kwargs_without_properties = {k: v for k, v in kwargs.items() if k != "properties"}
|
|
51
|
+
extracted_params.update(extract_input_params(args, kwargs_without_properties))
|
|
52
|
+
|
|
53
|
+
if kwargs.get("properties", None):
|
|
54
|
+
extracted_params["properties"] = []
|
|
55
|
+
for each_prop in kwargs.get("properties"):
|
|
56
|
+
if hasattr(each_prop, "_to_dict"):
|
|
57
|
+
# append properties to extracted_params
|
|
58
|
+
extracted_params["properties"].append(each_prop._to_dict())
|
|
59
|
+
|
|
60
|
+
extracted_params["properties"] = json.dumps(extracted_params["properties"])
|
|
61
|
+
return extracted_params
|
|
62
|
+
|
|
63
|
+
|
|
48
64
|
def extract_metadata(metadata):
|
|
49
65
|
# Extraction response Query metadata
|
|
50
66
|
extracted_metadata = {
|
|
@@ -126,7 +142,7 @@ def create_traced_method(method_name, version, tracer, get_collection_name=None)
|
|
|
126
142
|
"db.system": "weaviate",
|
|
127
143
|
"db.operation": api["OPERATION"],
|
|
128
144
|
"db.collection.name": collection_name,
|
|
129
|
-
"db.query": json.dumps(
|
|
145
|
+
"db.query": json.dumps(extract_inputs(args, kwargs)),
|
|
130
146
|
**(extra_attributes if extra_attributes is not None else {}),
|
|
131
147
|
}
|
|
132
148
|
|
|
@@ -143,7 +159,6 @@ def create_traced_method(method_name, version, tracer, get_collection_name=None)
|
|
|
143
159
|
try:
|
|
144
160
|
# Attempt to call the original method
|
|
145
161
|
result = wrapped(*args, **kwargs)
|
|
146
|
-
print(result)
|
|
147
162
|
if api["OPERATION"] in ["query", "generate"]:
|
|
148
163
|
span.add_event(
|
|
149
164
|
name="db.response",
|
langtrace_python_sdk/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "2.2.
|
|
1
|
+
__version__ = "2.2.25"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: langtrace-python-sdk
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.25
|
|
4
4
|
Summary: Python SDK for LangTrace
|
|
5
5
|
Project-URL: Homepage, https://github.com/Scale3-Labs/langtrace-python-sdk
|
|
6
6
|
Author-email: Scale3 Labs <engineering@scale3labs.com>
|
|
@@ -20,7 +20,7 @@ Requires-Dist: opentelemetry-instrumentation>=0.47b0
|
|
|
20
20
|
Requires-Dist: opentelemetry-sdk>=1.25.0
|
|
21
21
|
Requires-Dist: sqlalchemy
|
|
22
22
|
Requires-Dist: tiktoken>=0.1.1
|
|
23
|
-
Requires-Dist: trace-attributes==7.0.
|
|
23
|
+
Requires-Dist: trace-attributes==7.0.3
|
|
24
24
|
Provides-Extra: dev
|
|
25
25
|
Requires-Dist: anthropic; extra == 'dev'
|
|
26
26
|
Requires-Dist: chromadb; extra == 'dev'
|
|
@@ -71,10 +71,10 @@ examples/routellm_example/basic.py,sha256=6XYfs9Wu2ty-Kv8yiC5U49qJuTNv728xWKQsIm
|
|
|
71
71
|
examples/vertexai_example/__init__.py,sha256=sEKULUwHdn-CJnbYs_jt4QPAUnM_fqwMBI3HJ1RBZco,83
|
|
72
72
|
examples/vertexai_example/main.py,sha256=gndId5X5ksD-ycxnAWMdEqIDbLc3kz5Vt8vm4YPIk7I,5849
|
|
73
73
|
examples/weaviate_example/__init__.py,sha256=8JMDBsRSEV10HfTd-YC7xb4txBjD3la56snk-Bbg2Kw,618
|
|
74
|
-
examples/weaviate_example/query_text.py,sha256=
|
|
74
|
+
examples/weaviate_example/query_text.py,sha256=wPHQTc_58kPoKTZMygVjTj-2ZcdrIuaausJfMxNQnQc,127162
|
|
75
75
|
langtrace_python_sdk/__init__.py,sha256=VZM6i71NR7pBQK6XvJWRelknuTYUhqwqE7PlicKa5Wg,1166
|
|
76
76
|
langtrace_python_sdk/langtrace.py,sha256=5BL5lNZejLRq9AVuOCjFaPpIkFNUh2vLvlGSGVxUlE4,7974
|
|
77
|
-
langtrace_python_sdk/version.py,sha256=
|
|
77
|
+
langtrace_python_sdk/version.py,sha256=8xbzK-r35DSBokXIRfAv8IZHOXPKauxqDz3rOSngMig,23
|
|
78
78
|
langtrace_python_sdk/constants/__init__.py,sha256=P8QvYwt5czUNDZsKS64vxm9Dc41ptGbuF1TFtAF6nv4,44
|
|
79
79
|
langtrace_python_sdk/constants/exporter/langtrace_exporter.py,sha256=5MNjnAOg-4am78J3gVMH6FSwq5N8TOj72ugkhsw4vi0,46
|
|
80
80
|
langtrace_python_sdk/constants/instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -146,8 +146,8 @@ langtrace_python_sdk/instrumentation/vertexai/__init__.py,sha256=ZzKxB7bl0FaRlgJ
|
|
|
146
146
|
langtrace_python_sdk/instrumentation/vertexai/instrumentation.py,sha256=Keeb1D7nJDYu33w6H8Q8jLS7OOJtSIHqngvJMipWqJo,1143
|
|
147
147
|
langtrace_python_sdk/instrumentation/vertexai/patch.py,sha256=mfd3LiKYGMW3jLf9OEi7Iq9NUOThLskCqa_blvFmGV0,4489
|
|
148
148
|
langtrace_python_sdk/instrumentation/weaviate/__init__.py,sha256=Mc-Je6evPo-kKQzerTG7bd1XO5JOh4YGTE3wBxaUBwg,99
|
|
149
|
-
langtrace_python_sdk/instrumentation/weaviate/instrumentation.py,sha256=
|
|
150
|
-
langtrace_python_sdk/instrumentation/weaviate/patch.py,sha256=
|
|
149
|
+
langtrace_python_sdk/instrumentation/weaviate/instrumentation.py,sha256=bzPwtoQD0X6beLYXe6ZL7XRkyRkqdiqKiGc4gOlCQdU,2295
|
|
150
|
+
langtrace_python_sdk/instrumentation/weaviate/patch.py,sha256=nr7USyY6overK3GQCo4Si0x3eoEl9ptoMRXuQUP4Ox8,6671
|
|
151
151
|
langtrace_python_sdk/types/__init__.py,sha256=KDW6S74FDxpeBa9xoH5zVEYfmRjccCCHzlW7lTJg1TA,3194
|
|
152
152
|
langtrace_python_sdk/utils/__init__.py,sha256=SwYYPIh2AzEpI3zbwowQU2zJlwRwoVdWOCcrAKnkI9g,873
|
|
153
153
|
langtrace_python_sdk/utils/langtrace_sampler.py,sha256=BupNndHbU9IL_wGleKetz8FdcveqHMBVz1bfKTTW80w,1753
|
|
@@ -200,8 +200,8 @@ tests/pinecone/cassettes/test_query.yaml,sha256=b5v9G3ssUy00oG63PlFUR3JErF2Js-5A
|
|
|
200
200
|
tests/pinecone/cassettes/test_upsert.yaml,sha256=neWmQ1v3d03V8WoLl8FoFeeCYImb8pxlJBWnFd_lITU,38607
|
|
201
201
|
tests/qdrant/conftest.py,sha256=9n0uHxxIjWk9fbYc4bx-uP8lSAgLBVx-cV9UjnsyCHM,381
|
|
202
202
|
tests/qdrant/test_qdrant.py,sha256=pzjAjVY2kmsmGfrI2Gs2xrolfuaNHz7l1fqGQCjp5_o,3353
|
|
203
|
-
langtrace_python_sdk-2.2.
|
|
204
|
-
langtrace_python_sdk-2.2.
|
|
205
|
-
langtrace_python_sdk-2.2.
|
|
206
|
-
langtrace_python_sdk-2.2.
|
|
207
|
-
langtrace_python_sdk-2.2.
|
|
203
|
+
langtrace_python_sdk-2.2.25.dist-info/METADATA,sha256=N1w_sCc_3OMdsdme1UeDvS-h0jaG5VgN5YpXT6F9f00,14705
|
|
204
|
+
langtrace_python_sdk-2.2.25.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
205
|
+
langtrace_python_sdk-2.2.25.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
|
|
206
|
+
langtrace_python_sdk-2.2.25.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
207
|
+
langtrace_python_sdk-2.2.25.dist-info/RECORD,,
|
|
File without changes
|
{langtrace_python_sdk-2.2.24.dist-info → langtrace_python_sdk-2.2.25.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{langtrace_python_sdk-2.2.24.dist-info → langtrace_python_sdk-2.2.25.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|