langtrace-python-sdk 3.8.5__py3-none-any.whl → 3.8.6__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,9 +1,6 @@
1
1
  import json
2
2
  from typing import Any, Callable, List
3
3
 
4
- from agents.exceptions import (InputGuardrailTripwireTriggered,
5
- OutputGuardrailTripwireTriggered)
6
- from agents.run import Runner
7
4
  from importlib_metadata import version as v
8
5
  from langtrace.trace_attributes import FrameworkSpanAttributes, SpanAttributes
9
6
  from opentelemetry import baggage, trace
@@ -18,6 +15,29 @@ from langtrace_python_sdk.utils.llm import (set_event_completion,
18
15
  set_usage_attributes)
19
16
 
20
17
 
18
+ # Define dummy classes to use when imports fail
19
+ class DummyRunner:
20
+ pass
21
+
22
+
23
+ class DummyException(Exception):
24
+ pass
25
+
26
+
27
+ # Try importing from openai-agents package
28
+ try:
29
+ from agents.exceptions import (InputGuardrailTripwireTriggered,
30
+ OutputGuardrailTripwireTriggered)
31
+ from agents.run import Runner
32
+ OPENAI_AGENTS_AVAILABLE = True
33
+ except ImportError:
34
+ # Define dummy classes if imports fail
35
+ InputGuardrailTripwireTriggered = DummyException
36
+ OutputGuardrailTripwireTriggered = DummyException
37
+ Runner = DummyRunner
38
+ OPENAI_AGENTS_AVAILABLE = False
39
+
40
+
21
41
  def extract_agent_details(agent_or_handoff):
22
42
  """Extract relevant details from an agent/handoff and its handoffs."""
23
43
  try:
@@ -70,6 +90,10 @@ def extract_handoff_details(handoff):
70
90
 
71
91
  def get_handoffs(version: str, tracer: Tracer) -> Callable:
72
92
  """Wrap the `prompt` method of the `TLM` class to trace it."""
93
+ if not OPENAI_AGENTS_AVAILABLE:
94
+ def noop_traced_method(wrapped: Callable, instance: Any, args: List[Any], kwargs: Any) -> Any:
95
+ return wrapped(*args, **kwargs)
96
+ return noop_traced_method
73
97
 
74
98
  def traced_method(
75
99
  wrapped: Callable,
@@ -117,7 +141,8 @@ def get_handoffs(version: str, tracer: Tracer) -> Callable:
117
141
  attributes = FrameworkSpanAttributes(**span_attributes)
118
142
 
119
143
  with tracer.start_as_current_span(
120
- name=f"openai_agents.available_handoffs", kind=SpanKind.CLIENT
144
+ name="openai_agents.available_handoffs",
145
+ kind=SpanKind.CLIENT
121
146
  ) as span:
122
147
  try:
123
148
  set_span_attributes(span, attributes)
@@ -157,12 +182,11 @@ def get_handoffs(version: str, tracer: Tracer) -> Callable:
157
182
  pass # Silently fail if error recording fails
158
183
  raise # Re-raise the original error since it's from the wrapped function
159
184
 
160
- except Exception as outer_err:
161
- # If anything fails in our instrumentation wrapper, catch it and return control to the wrapped function
185
+ except Exception:
162
186
  try:
163
187
  return wrapped(*args, **kwargs)
164
188
  except Exception as wrapped_err:
165
- raise wrapped_err # Only raise errors from the wrapped function
189
+ raise wrapped_err
166
190
 
167
191
  return traced_method
168
192
 
@@ -328,6 +352,10 @@ def extract_run_config(config):
328
352
 
329
353
  def get_new_response(version: str, tracer: Tracer) -> Callable:
330
354
  """Wrap the _get_new_response method to trace inputs and outputs."""
355
+ if not OPENAI_AGENTS_AVAILABLE:
356
+ async def noop_traced_method(wrapped: Callable, instance: Any, args: List[Any], kwargs: Any) -> Any:
357
+ return await wrapped(*args, **kwargs)
358
+ return noop_traced_method
331
359
 
332
360
  async def traced_method(
333
361
  wrapped: Callable,
@@ -524,7 +552,7 @@ def get_new_response(version: str, tracer: Tracer) -> Callable:
524
552
 
525
553
  raise
526
554
 
527
- except Exception as outer_err:
555
+ except Exception: # Remove outer_err since it's unused
528
556
  try:
529
557
  return await wrapped(*args, **kwargs)
530
558
  except Exception as wrapped_err:
@@ -1 +1 @@
1
- __version__ = "3.8.5"
1
+ __version__ = "3.8.6"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langtrace-python-sdk
3
- Version: 3.8.5
3
+ Version: 3.8.6
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>
@@ -116,7 +116,7 @@ examples/weaviate_example/__init__.py,sha256=8JMDBsRSEV10HfTd-YC7xb4txBjD3la56sn
116
116
  examples/weaviate_example/query_text.py,sha256=wPHQTc_58kPoKTZMygVjTj-2ZcdrIuaausJfMxNQnQc,127162
117
117
  langtrace_python_sdk/__init__.py,sha256=VZM6i71NR7pBQK6XvJWRelknuTYUhqwqE7PlicKa5Wg,1166
118
118
  langtrace_python_sdk/langtrace.py,sha256=T-DsDrwWaL4gAUK1lkTRRpmvoO7F2WtO5hQZdyrVAxE,13791
119
- langtrace_python_sdk/version.py,sha256=mb3dZLLIE3dKNa7hv1kuERgx4o1UEUlj7DsxZRc2A38,22
119
+ langtrace_python_sdk/version.py,sha256=L1_tSVoK2Iu6e_MbZl4Kogu3ops-t44WVGFD8F6BeAc,22
120
120
  langtrace_python_sdk/constants/__init__.py,sha256=3CNYkWMdd1DrkGqzLUgNZXjdAlM6UFMlf_F-odAToyc,146
121
121
  langtrace_python_sdk/constants/exporter/langtrace_exporter.py,sha256=EVCrouYCpY98f0KSaKr4PzNxPULTZZO6dSA_crEOyJU,106
122
122
  langtrace_python_sdk/constants/instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -227,7 +227,7 @@ langtrace_python_sdk/instrumentation/openai/patch.py,sha256=mRE150sHGL2dq4oOKTYW
227
227
  langtrace_python_sdk/instrumentation/openai/types.py,sha256=aVkoa7tmAbYfyOhnyMrDaVjQuwhmRNLMthlNtKMtWX8,4311
228
228
  langtrace_python_sdk/instrumentation/openai_agents/__init__.py,sha256=ElRfFIQYXD2-eRyL3fZnjIsDJLTrDolh5cZHPnZv0q8,107
229
229
  langtrace_python_sdk/instrumentation/openai_agents/instrumentation.py,sha256=6M4FHXfem7pazrNgsimebrEfMb2FxI8lHrdEMbVf75Y,1860
230
- langtrace_python_sdk/instrumentation/openai_agents/patch.py,sha256=zXuIjqnPvWNEu8nCDTRxxvTAi8PwAOsBJEtsFn3PXaI,24012
230
+ langtrace_python_sdk/instrumentation/openai_agents/patch.py,sha256=-53a317SCmwnI5s1vgZZBs3RkmRpVjwaTQSZKiwR5Vs,24772
231
231
  langtrace_python_sdk/instrumentation/phidata/__init__.py,sha256=q2v6luvqp9gFf1AJX6YrBvuyMC_q6cEnB5syl2HNPlU,97
232
232
  langtrace_python_sdk/instrumentation/phidata/instrumentation.py,sha256=S639XMVOGmpIK9jug9NWrUBLqs1G5ywBZiIhVuCkwGk,2697
233
233
  langtrace_python_sdk/instrumentation/phidata/patch.py,sha256=-Jf_20wLLRGRM6sY3RreS-ocXjdq5m33-gxNtl_eUdQ,12133
@@ -300,8 +300,8 @@ tests/pinecone/cassettes/test_query.yaml,sha256=b5v9G3ssUy00oG63PlFUR3JErF2Js-5A
300
300
  tests/pinecone/cassettes/test_upsert.yaml,sha256=neWmQ1v3d03V8WoLl8FoFeeCYImb8pxlJBWnFd_lITU,38607
301
301
  tests/qdrant/conftest.py,sha256=9n0uHxxIjWk9fbYc4bx-uP8lSAgLBVx-cV9UjnsyCHM,381
302
302
  tests/qdrant/test_qdrant.py,sha256=pzjAjVY2kmsmGfrI2Gs2xrolfuaNHz7l1fqGQCjp5_o,3353
303
- langtrace_python_sdk-3.8.5.dist-info/METADATA,sha256=oM9Ya7m7DDYBDT1VtPe3uguAKkvdJImtz2WGgSxmLbo,15844
304
- langtrace_python_sdk-3.8.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
305
- langtrace_python_sdk-3.8.5.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
306
- langtrace_python_sdk-3.8.5.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
307
- langtrace_python_sdk-3.8.5.dist-info/RECORD,,
303
+ langtrace_python_sdk-3.8.6.dist-info/METADATA,sha256=4oUaxQYAGDXx_tRBdNnMja_qs0XOH-KOTYSwWizKc4g,15844
304
+ langtrace_python_sdk-3.8.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
305
+ langtrace_python_sdk-3.8.6.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
306
+ langtrace_python_sdk-3.8.6.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
307
+ langtrace_python_sdk-3.8.6.dist-info/RECORD,,