langtrace-python-sdk 2.1.6__py3-none-any.whl → 2.1.8__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.
@@ -1,4 +1,8 @@
1
- # export OPENAI_APIKEY=sk-<OPENAI API KEY>
1
+ # export OPENAI_API_KEY=sk-<OPENAI API KEY>
2
+ # export WCS_DEMO_URL=https://<CLUSTER ID>.weaviate.cloud
3
+ # export WCS_DEMO_RO_KEY=<YOUR READ ONLY KEY>
4
+ # export LANGTRACE_API_KEY=<YOUR LANGTRACE API KEY>
5
+
2
6
  # python main.py
3
7
 
4
8
  # Example taken from startup guide
@@ -27,7 +31,7 @@ client = weaviate.connect_to_wcs(
27
31
  cluster_url=WCS_DEMO_URL,
28
32
  auth_credentials=weaviate.auth.AuthApiKey(WCS_DEMO_RO_KEY),
29
33
  skip_init_checks=True,
30
- headers={"X-OpenAI-Api-Key": os.environ["OPENAI_APIKEY"]},
34
+ headers={"X-OpenAI-Api-Key": os.environ["OPENAI_API_KEY"]},
31
35
  )
32
36
 
33
37
  langtrace.init()
@@ -17,16 +17,16 @@ limitations under the License.
17
17
  import importlib.metadata
18
18
  import logging
19
19
  from typing import Collection
20
- from opentelemetry.instrumentation.utils import unwrap
20
+
21
21
  from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
22
22
  from opentelemetry.trace import get_tracer
23
23
  from wrapt import wrap_function_wrapper
24
24
 
25
+ from langtrace_python_sdk.constants.instrumentation.weaviate import APIS
25
26
  from langtrace_python_sdk.instrumentation.weaviate.patch import (
26
27
  generic_collection_patch,
27
28
  generic_query_patch,
28
29
  )
29
- from langtrace_python_sdk.constants.instrumentation.weaviate import APIS
30
30
 
31
31
  logging.basicConfig(level=logging.DEBUG) # Set to DEBUG for detailed logging
32
32
 
@@ -45,21 +45,18 @@ class WeaviateInstrumentation(BaseInstrumentor):
45
45
  version = importlib.metadata.version("weaviate-client")
46
46
 
47
47
  for api_name, api_config in APIS.items():
48
- module_path, function_name = api_name.rsplit(".", 1)
49
48
  if api_config.get("OPERATION") == "query":
50
- if getattr(api_config["MODULE"], api_config["METHOD"], None):
51
- wrap_function_wrapper(
52
- api_config["MODULE"],
53
- api_config["METHOD"],
54
- generic_query_patch(api_name, version, tracer),
55
- )
49
+ wrap_function_wrapper(
50
+ api_config["MODULE"],
51
+ api_config["METHOD"],
52
+ generic_query_patch(api_name, version, tracer),
53
+ )
56
54
  elif api_config.get("OPERATION") == "create":
57
- if getattr(api_config["MODULE"], api_config["METHOD"], None):
58
- wrap_function_wrapper(
59
- api_config["MODULE"],
60
- api_config["METHOD"],
61
- generic_collection_patch(api_name, version, tracer),
62
- )
55
+ wrap_function_wrapper(
56
+ api_config["MODULE"],
57
+ api_config["METHOD"],
58
+ generic_collection_patch(api_name, version, tracer),
59
+ )
63
60
 
64
61
  def _instrument_module(self, module_name):
65
62
  pass
@@ -45,6 +45,7 @@ from langtrace_python_sdk.instrumentation import (
45
45
  )
46
46
  from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
47
47
  from colorama import Fore
48
+ from langtrace_python_sdk.utils import check_if_sdk_is_outdated
48
49
 
49
50
 
50
51
  def init(
@@ -55,6 +56,7 @@ def init(
55
56
  api_host: Optional[str] = None,
56
57
  disable_instrumentations: Optional[DisableInstrumentations] = None,
57
58
  ):
59
+ check_if_sdk_is_outdated()
58
60
  print(Fore.GREEN + "Initializing Langtrace SDK.." + Fore.RESET)
59
61
  provider = TracerProvider(resource=Resource.create({"service.name": sys.argv[0]}))
60
62
 
@@ -1,5 +1,13 @@
1
+ from .sdk_version_checker import SDKVersionChecker
2
+
3
+
1
4
  def set_span_attribute(span, name, value):
2
5
  if value is not None:
3
6
  if value != "":
4
7
  span.set_attribute(name, value)
5
8
  return
9
+
10
+
11
+ def check_if_sdk_is_outdated():
12
+ SDKVersionChecker().check()
13
+ return
@@ -0,0 +1,48 @@
1
+ from importlib.metadata import version
2
+ import time
3
+ import requests
4
+ from colorama import Fore
5
+
6
+
7
+ class SDKVersionChecker:
8
+ _cache: None
9
+ _cache_duration: int
10
+ _current_version: str
11
+ _latest_version: str
12
+
13
+ def __init__(self):
14
+ self._cache = {"timestamp": 0, "latest_version": None}
15
+ self._cache_duration = 3600 # Cache for 1 hour
16
+ self._current_version = version("langtrace_python_sdk")
17
+
18
+ def fetch_latest(self):
19
+ current_time = time.time()
20
+ if (
21
+ current_time - self._cache["timestamp"] < self._cache_duration
22
+ and self._cache["latest_version"]
23
+ ):
24
+ return self._cache["latest_version"]
25
+
26
+ response = requests.get(
27
+ "https://api.github.com/repos/Scale3-Labs/langtrace-python-sdk/releases/latest",
28
+ timeout=20,
29
+ )
30
+ response.raise_for_status()
31
+ latest_version = response.json()["tag_name"]
32
+ self._cache.update(
33
+ {"timestamp": current_time, "latest_version": latest_version}
34
+ )
35
+ self._latest_version = latest_version
36
+ return latest_version
37
+
38
+ def is_outdated(self):
39
+ latest_version = self.fetch_latest()
40
+ return self._current_version < latest_version
41
+
42
+ def check(self):
43
+ if self.is_outdated():
44
+ print(
45
+ Fore.YELLOW
46
+ + f"Warning: Your Langtrace SDK version {self._current_version} is outdated. Please upgrade to {self._latest_version}."
47
+ + Fore.RESET
48
+ )
@@ -1 +1 @@
1
- __version__ = "2.1.6"
1
+ __version__ = "2.1.8"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: langtrace-python-sdk
3
- Version: 2.1.6
3
+ Version: 2.1.8
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>
@@ -11,12 +11,12 @@ Classifier: Operating System :: OS Independent
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Requires-Python: >=3.9
13
13
  Requires-Dist: colorama>=0.4.6
14
- Requires-Dist: opentelemetry-api>=1.24.0
15
- Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.24.0
16
- Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.24.0
17
- Requires-Dist: opentelemetry-instrumentation-sqlalchemy>=0.45b0
18
- Requires-Dist: opentelemetry-instrumentation>=0.45b0
19
- Requires-Dist: opentelemetry-sdk>=1.24.0
14
+ Requires-Dist: opentelemetry-api>=1.25.0
15
+ Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.25.0
16
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.25.0
17
+ Requires-Dist: opentelemetry-instrumentation-sqlalchemy>=0.46b0
18
+ Requires-Dist: opentelemetry-instrumentation>=0.46b0
19
+ Requires-Dist: opentelemetry-sdk>=1.25.0
20
20
  Requires-Dist: sqlalchemy
21
21
  Requires-Dist: tiktoken>=0.1.1
22
22
  Requires-Dist: trace-attributes>=4.0.4
@@ -35,10 +35,10 @@ examples/pinecone_example/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
35
35
  examples/pinecone_example/basic.py,sha256=b-5-cSf3_N6Gk4zGVecGF47mBcFY9ZrC5ztrIZVgTQo,1430
36
36
  examples/qdrant_example/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  examples/qdrant_example/basic.py,sha256=DCMjHSuBZKkhEjCkwy5d5La9WMyW0lCWqtcZWiFCEm4,1425
38
- examples/weaviate_example/query_text.py,sha256=yhBCmJ61llKL5T92s1_R7yihS6koys2AJQWZXSYIT9w,64491
38
+ examples/weaviate_example/query_text.py,sha256=iE9OiHsibjsprbCGzabE03eZsGN06e6ym2iS1A9P3ig,64650
39
39
  langtrace_python_sdk/__init__.py,sha256=R4dv73QARUw4WRfCdSKkKzZTLDumF9jcSdwtVrzWhb4,962
40
- langtrace_python_sdk/langtrace.py,sha256=h168V4kyqSezozDnMVar2Xgbi764WvVA_PpSgVuBzz0,6560
41
- langtrace_python_sdk/version.py,sha256=Z4RaxSmfOjvKssLeOljGX3Csb8I17J-Dc7pSVg3Hb2U,22
40
+ langtrace_python_sdk/langtrace.py,sha256=_qJsbLo-4GqhXd8apg3W7A_l3ZnFYEX1wOA-_rg-TZA,6655
41
+ langtrace_python_sdk/version.py,sha256=Zs7yBsCpiMSJW2PP_mZoH_3cEDqJwh80ulBcmuMBwMU,22
42
42
  langtrace_python_sdk/constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
43
  langtrace_python_sdk/constants/exporter/langtrace_exporter.py,sha256=5MNjnAOg-4am78J3gVMH6FSwq5N8TOj72ugkhsw4vi0,46
44
44
  langtrace_python_sdk/constants/instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -91,13 +91,14 @@ langtrace_python_sdk/instrumentation/qdrant/__init__.py,sha256=TaIGSAEPysrL23KJ5
91
91
  langtrace_python_sdk/instrumentation/qdrant/instrumentation.py,sha256=vl2eKSP55aqDo1JiRlvOUBrr6kddvG9Z5dCYew2OG08,1816
92
92
  langtrace_python_sdk/instrumentation/qdrant/patch.py,sha256=KcUWmvnS3PgPStzs1oWmlZsyomKBl3dmg8nXuR0T1C0,4654
93
93
  langtrace_python_sdk/instrumentation/weaviate/__init__.py,sha256=Mc-Je6evPo-kKQzerTG7bd1XO5JOh4YGTE3wBxaUBwg,99
94
- langtrace_python_sdk/instrumentation/weaviate/instrumentation.py,sha256=4BnHRzXOKEauy2TNTZwpIagDFUp03CUyBZCdE2vinxk,2596
94
+ langtrace_python_sdk/instrumentation/weaviate/instrumentation.py,sha256=Dn2wMj__nNZkUtDw_jEYslE8-bz2KGkdAU_t8qzWjuA,2281
95
95
  langtrace_python_sdk/instrumentation/weaviate/patch.py,sha256=ig2fc33hNydEcH5cJWRycFnMXiXiJr731J-Vg5Ze4No,5634
96
96
  langtrace_python_sdk/types/__init__.py,sha256=-j8cuz3bhUdOqj7N2c0w5y-j3UmcxwEgNh8BWeXwHoI,813
97
- langtrace_python_sdk/utils/__init__.py,sha256=MbBqT4NpDCNTqqvZ0lG4tRiFFZ-tlM8Dwophg4xyrRw,148
97
+ langtrace_python_sdk/utils/__init__.py,sha256=E0nQyBE-4O_GR2PM9y_l7shx4hJLo5xRThR_LMx97M0,278
98
98
  langtrace_python_sdk/utils/llm.py,sha256=CiASOvObFvsN6T7ogWywNXfXGzI__u9misgolLxyeZk,2161
99
99
  langtrace_python_sdk/utils/misc.py,sha256=CD9NWRLxLpFd0YwlHJqzlpFNedXVWtAKGOjQWnDCo8k,838
100
100
  langtrace_python_sdk/utils/prompt_registry.py,sha256=7FFB4Pj0414qgf02h5zL5vXBZgNBf74g4Iq7GdFaIO0,2689
101
+ langtrace_python_sdk/utils/sdk_version_checker.py,sha256=_ZqW7y-aP5qddbObbM_gMlmhCZbnIH83C1pa_KN8glE,1523
101
102
  langtrace_python_sdk/utils/silently_fail.py,sha256=F_9EteXCO9Cyq-8MA1OT2Zy_dx8n06nt31I7t7ui24E,478
102
103
  langtrace_python_sdk/utils/types.py,sha256=l-N6o7cnWUyrD6dBvW7W3Pf5CkPo5QaoT__k1XLbrQg,383
103
104
  langtrace_python_sdk/utils/with_root_span.py,sha256=rSPrTnKndJo6cFUWL4907IkJFbtLwqMS87paADUxD6A,5957
@@ -137,7 +138,7 @@ tests/pinecone/cassettes/test_query.yaml,sha256=b5v9G3ssUy00oG63PlFUR3JErF2Js-5A
137
138
  tests/pinecone/cassettes/test_upsert.yaml,sha256=neWmQ1v3d03V8WoLl8FoFeeCYImb8pxlJBWnFd_lITU,38607
138
139
  tests/qdrant/conftest.py,sha256=9n0uHxxIjWk9fbYc4bx-uP8lSAgLBVx-cV9UjnsyCHM,381
139
140
  tests/qdrant/test_qdrant.py,sha256=pzjAjVY2kmsmGfrI2Gs2xrolfuaNHz7l1fqGQCjp5_o,3353
140
- langtrace_python_sdk-2.1.6.dist-info/METADATA,sha256=LyeAdMQ4pEop6qBT67NVu3BljAEIt3eQXKH-57HsvEM,11859
141
- langtrace_python_sdk-2.1.6.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
142
- langtrace_python_sdk-2.1.6.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
143
- langtrace_python_sdk-2.1.6.dist-info/RECORD,,
141
+ langtrace_python_sdk-2.1.8.dist-info/METADATA,sha256=ZvEU8PvKSRRRttRHq2cOPOlMDWFjA9PS3k3zjhJgnCY,11859
142
+ langtrace_python_sdk-2.1.8.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
143
+ langtrace_python_sdk-2.1.8.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
144
+ langtrace_python_sdk-2.1.8.dist-info/RECORD,,