langtrace-python-sdk 2.1.26__py3-none-any.whl → 2.1.27__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.
@@ -28,7 +28,11 @@ from langtrace_python_sdk.constants.instrumentation.common import (
28
28
  SERVICE_PROVIDERS,
29
29
  )
30
30
  from langtrace_python_sdk.constants.instrumentation.openai import APIS
31
- from langtrace_python_sdk.utils.llm import calculate_prompt_tokens, estimate_tokens
31
+ from langtrace_python_sdk.utils.llm import (
32
+ calculate_prompt_tokens,
33
+ estimate_tokens,
34
+ get_tool_calls,
35
+ )
32
36
  from openai._types import NOT_GIVEN
33
37
 
34
38
 
@@ -430,9 +434,10 @@ def chat_completions_create(original_method, version, tracer):
430
434
  # handle tool calls in the kwargs
431
435
  llm_prompts = []
432
436
  for item in kwargs.get("messages", []):
433
- if hasattr(item, "tool_calls") and item.tool_calls is not None:
437
+ tools = get_tool_calls(item)
438
+ if tools is not None:
434
439
  tool_calls = []
435
- for tool_call in item.tool_calls:
440
+ for tool_call in tools:
436
441
  tool_call_dict = {
437
442
  "id": tool_call.id if hasattr(tool_call, "id") else "",
438
443
  "type": tool_call.type if hasattr(tool_call, "type") else "",
@@ -611,9 +616,10 @@ def async_chat_completions_create(original_method, version, tracer):
611
616
  # handle tool calls in the kwargs
612
617
  llm_prompts = []
613
618
  for item in kwargs.get("messages", []):
614
- if hasattr(item, "tool_calls") and item.tool_calls is not None:
619
+ tools = get_tool_calls(item)
620
+ if tools is not None:
615
621
  tool_calls = []
616
- for tool_call in item.tool_calls:
622
+ for tool_call in tools:
617
623
  tool_call_dict = {
618
624
  "id": tool_call.id if hasattr(tool_call, "id") else "",
619
625
  "type": tool_call.type if hasattr(tool_call, "type") else "",
@@ -65,3 +65,15 @@ def set_span_attributes(span, name, value):
65
65
  if value != "":
66
66
  span.set_attribute(name, value)
67
67
  return
68
+
69
+
70
+ def get_tool_calls(item):
71
+ if isinstance(item, dict):
72
+ if "tool_calls" in item and item["tool_calls"] is not None:
73
+ return item["tool_calls"]
74
+ return None
75
+
76
+ else:
77
+ if hasattr(item, "tool_calls") and item.tool_calls is not None:
78
+ return item.tool_calls
79
+ return None
@@ -1 +1 @@
1
- __version__ = "2.1.26"
1
+ __version__ = "2.1.27"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: langtrace-python-sdk
3
- Version: 2.1.26
3
+ Version: 2.1.27
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>
@@ -51,7 +51,7 @@ examples/weaviate_example/__init__.py,sha256=8JMDBsRSEV10HfTd-YC7xb4txBjD3la56sn
51
51
  examples/weaviate_example/query_text.py,sha256=sG8O-bXQpflBAiYpgE_M2X7GcHUlZNgl_wJW8_h-W6Q,127024
52
52
  langtrace_python_sdk/__init__.py,sha256=VZM6i71NR7pBQK6XvJWRelknuTYUhqwqE7PlicKa5Wg,1166
53
53
  langtrace_python_sdk/langtrace.py,sha256=pG_dWzzQxUP8r5SAMUwRScb6IopINcda1CZvJERjXBo,7486
54
- langtrace_python_sdk/version.py,sha256=kDsQujSOEts9DhAOHBOlEjAEDf0lqYMUYrA9xzjlvh0,23
54
+ langtrace_python_sdk/version.py,sha256=nRu7ZwJqfHD5II0bBxcWlJ8czOdWw1bjjPVhymDs-NE,23
55
55
  langtrace_python_sdk/constants/__init__.py,sha256=P8QvYwt5czUNDZsKS64vxm9Dc41ptGbuF1TFtAF6nv4,44
56
56
  langtrace_python_sdk/constants/exporter/langtrace_exporter.py,sha256=5MNjnAOg-4am78J3gVMH6FSwq5N8TOj72ugkhsw4vi0,46
57
57
  langtrace_python_sdk/constants/instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -107,7 +107,7 @@ langtrace_python_sdk/instrumentation/ollama/instrumentation.py,sha256=jdsvkqUJAA
107
107
  langtrace_python_sdk/instrumentation/ollama/patch.py,sha256=uzoc2M-Vj-wEnjYBiiR8lg1s9teqMz6bG4iS6s1_QiQ,8639
108
108
  langtrace_python_sdk/instrumentation/openai/__init__.py,sha256=VPHRNCQEdkizIVP2d0Uw_a7t8XOTSTprEIB8oboJFbs,95
109
109
  langtrace_python_sdk/instrumentation/openai/instrumentation.py,sha256=A0BJHRLcZ74TNVg6I0I9M5YWvSpAtXwMmME6N5CEQ_M,2945
110
- langtrace_python_sdk/instrumentation/openai/patch.py,sha256=MJGxa7w5FyGNf4PA4VpnhcO0D2HOHjY8YcroziSAXhE,38341
110
+ langtrace_python_sdk/instrumentation/openai/patch.py,sha256=C1Bb__IweKKjImBC8VVXG-2wpqQb7ogyIdWPx6pdTM8,38352
111
111
  langtrace_python_sdk/instrumentation/pinecone/__init__.py,sha256=DzXyGh9_MGWveJvXULkFwdkf7PbG2s3bAWtT1Dmz7Ok,99
112
112
  langtrace_python_sdk/instrumentation/pinecone/instrumentation.py,sha256=HDXkRITrVPwdQEoOYJOfMzZE_2-vDDvuqHTlD8W1lQw,1845
113
113
  langtrace_python_sdk/instrumentation/pinecone/patch.py,sha256=KiIRRz8kk47FllFT746Cb_w6F6M60AN_pcsguD979E4,5172
@@ -120,7 +120,7 @@ langtrace_python_sdk/instrumentation/weaviate/patch.py,sha256=rRD6WfQcNGYpw9teoC
120
120
  langtrace_python_sdk/types/__init__.py,sha256=KDW6S74FDxpeBa9xoH5zVEYfmRjccCCHzlW7lTJg1TA,3194
121
121
  langtrace_python_sdk/utils/__init__.py,sha256=E0nQyBE-4O_GR2PM9y_l7shx4hJLo5xRThR_LMx97M0,278
122
122
  langtrace_python_sdk/utils/langtrace_sampler.py,sha256=BupNndHbU9IL_wGleKetz8FdcveqHMBVz1bfKTTW80w,1753
123
- langtrace_python_sdk/utils/llm.py,sha256=CiASOvObFvsN6T7ogWywNXfXGzI__u9misgolLxyeZk,2161
123
+ langtrace_python_sdk/utils/llm.py,sha256=Lwa0zdKcXozOvYSDfIJNoWdI8zUGJqiraFilXipW4x0,2484
124
124
  langtrace_python_sdk/utils/misc.py,sha256=CD9NWRLxLpFd0YwlHJqzlpFNedXVWtAKGOjQWnDCo8k,838
125
125
  langtrace_python_sdk/utils/prompt_registry.py,sha256=-BNHX_UPAqBG1IdNUXZIA669M59wvFTyTvBifrFjy3k,2600
126
126
  langtrace_python_sdk/utils/sdk_version_checker.py,sha256=FzjIWZjn53cX0LEVPdipQd1fO9lG8iGVUEVUs9Hyk6M,1713
@@ -163,8 +163,8 @@ tests/pinecone/cassettes/test_query.yaml,sha256=b5v9G3ssUy00oG63PlFUR3JErF2Js-5A
163
163
  tests/pinecone/cassettes/test_upsert.yaml,sha256=neWmQ1v3d03V8WoLl8FoFeeCYImb8pxlJBWnFd_lITU,38607
164
164
  tests/qdrant/conftest.py,sha256=9n0uHxxIjWk9fbYc4bx-uP8lSAgLBVx-cV9UjnsyCHM,381
165
165
  tests/qdrant/test_qdrant.py,sha256=pzjAjVY2kmsmGfrI2Gs2xrolfuaNHz7l1fqGQCjp5_o,3353
166
- langtrace_python_sdk-2.1.26.dist-info/METADATA,sha256=YNNbDWGqNpHo-uWbngCA_l7MUhQd6brocjtLbWvGuio,13749
167
- langtrace_python_sdk-2.1.26.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
168
- langtrace_python_sdk-2.1.26.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
169
- langtrace_python_sdk-2.1.26.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
170
- langtrace_python_sdk-2.1.26.dist-info/RECORD,,
166
+ langtrace_python_sdk-2.1.27.dist-info/METADATA,sha256=Y2VR3lHrkaoLITUKX2xioU6S-2SBOuOyDABhceJD0U0,13749
167
+ langtrace_python_sdk-2.1.27.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
168
+ langtrace_python_sdk-2.1.27.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
169
+ langtrace_python_sdk-2.1.27.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
170
+ langtrace_python_sdk-2.1.27.dist-info/RECORD,,