langtrace-python-sdk 2.3.14__py3-none-any.whl → 2.3.15__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,5 @@
1
1
  import json
2
+ import openai
2
3
  from typing import Any, Dict, List, Optional, Callable, Awaitable, Union
3
4
  from langtrace.trace_attributes import (
4
5
  LLMSpanAttributes,
@@ -40,6 +41,15 @@ from langtrace_python_sdk.instrumentation.openai.types import (
40
41
  )
41
42
 
42
43
 
44
+ def filter_valid_attributes(attributes):
45
+ """Filter attributes where value is not None, not an empty string, and not openai.NOT_GIVEN."""
46
+ return {
47
+ key: value
48
+ for key, value in attributes.items()
49
+ if value is not None and value != openai.NOT_GIVEN and value != ""
50
+ }
51
+
52
+
43
53
  def images_generate(version: str, tracer: Tracer) -> Callable:
44
54
  """
45
55
  Wrap the `generate` method of the `Images` class to trace it.
@@ -57,7 +67,7 @@ def images_generate(version: str, tracer: Tracer) -> Callable:
57
67
  **get_extra_attributes(), # type: ignore
58
68
  }
59
69
 
60
- attributes = LLMSpanAttributes(**span_attributes)
70
+ attributes = LLMSpanAttributes(**filter_valid_attributes(span_attributes))
61
71
 
62
72
  with tracer.start_as_current_span(
63
73
  name=get_span_name(APIS["IMAGES_GENERATION"]["METHOD"]),
@@ -118,7 +128,7 @@ def async_images_generate(version: str, tracer: Tracer) -> Callable:
118
128
  **get_extra_attributes(), # type: ignore
119
129
  }
120
130
 
121
- attributes = LLMSpanAttributes(**span_attributes)
131
+ attributes = LLMSpanAttributes(**filter_valid_attributes(span_attributes))
122
132
 
123
133
  with tracer.start_as_current_span(
124
134
  name=get_span_name(APIS["IMAGES_GENERATION"]["METHOD"]),
@@ -181,7 +191,7 @@ def images_edit(version: str, tracer: Tracer) -> Callable:
181
191
  **get_extra_attributes(), # type: ignore
182
192
  }
183
193
 
184
- attributes = LLMSpanAttributes(**span_attributes)
194
+ attributes = LLMSpanAttributes(**filter_valid_attributes(span_attributes))
185
195
 
186
196
  with tracer.start_as_current_span(
187
197
  name=APIS["IMAGES_EDIT"]["METHOD"],
@@ -268,7 +278,7 @@ def chat_completions_create(version: str, tracer: Tracer) -> Callable:
268
278
  **get_extra_attributes(), # type: ignore
269
279
  }
270
280
 
271
- attributes = LLMSpanAttributes(**span_attributes)
281
+ attributes = LLMSpanAttributes(**filter_valid_attributes(span_attributes))
272
282
 
273
283
  span = tracer.start_span(
274
284
  name=get_span_name(APIS["CHAT_COMPLETION"]["METHOD"]),
@@ -356,7 +366,7 @@ def async_chat_completions_create(version: str, tracer: Tracer) -> Callable:
356
366
  **get_extra_attributes(), # type: ignore
357
367
  }
358
368
 
359
- attributes = LLMSpanAttributes(**span_attributes)
369
+ attributes = LLMSpanAttributes(**filter_valid_attributes(span_attributes))
360
370
 
361
371
  span = tracer.start_span(
362
372
  name=get_span_name(APIS["CHAT_COMPLETION"]["METHOD"]),
@@ -438,7 +448,7 @@ def embeddings_create(version: str, tracer: Tracer) -> Callable:
438
448
  [kwargs.get("input", "")]
439
449
  )
440
450
 
441
- attributes = LLMSpanAttributes(**span_attributes)
451
+ attributes = LLMSpanAttributes(**filter_valid_attributes(span_attributes))
442
452
 
443
453
  with tracer.start_as_current_span(
444
454
  name=get_span_name(APIS["EMBEDDINGS_CREATE"]["METHOD"]),
@@ -487,7 +497,7 @@ def async_embeddings_create(version: str, tracer: Tracer) -> Callable:
487
497
  **get_extra_attributes(), # type: ignore
488
498
  }
489
499
 
490
- attributes = LLMSpanAttributes(**span_attributes)
500
+ attributes = LLMSpanAttributes(**filter_valid_attributes(span_attributes))
491
501
 
492
502
  encoding_format = kwargs.get("encoding_format")
493
503
  if encoding_format is not None:
@@ -1 +1 @@
1
- __version__ = "2.3.14"
1
+ __version__ = "2.3.15"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: langtrace-python-sdk
3
- Version: 2.3.14
3
+ Version: 2.3.15
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>
@@ -92,7 +92,7 @@ examples/weaviate_example/__init__.py,sha256=8JMDBsRSEV10HfTd-YC7xb4txBjD3la56sn
92
92
  examples/weaviate_example/query_text.py,sha256=wPHQTc_58kPoKTZMygVjTj-2ZcdrIuaausJfMxNQnQc,127162
93
93
  langtrace_python_sdk/__init__.py,sha256=VZM6i71NR7pBQK6XvJWRelknuTYUhqwqE7PlicKa5Wg,1166
94
94
  langtrace_python_sdk/langtrace.py,sha256=SmDig6WHYGmM0dUcguWs8J3S5fuSItHiyf8Sf-OnLDI,9858
95
- langtrace_python_sdk/version.py,sha256=ezCBY1dWYKVlRARVZudr7rvPqU59svV18xDMDMGYnoc,23
95
+ langtrace_python_sdk/version.py,sha256=28uCRGLGQpYyjTS7Xuf21mpa3DD6nxVLN3iZBXYnKlo,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
@@ -165,7 +165,7 @@ langtrace_python_sdk/instrumentation/ollama/instrumentation.py,sha256=jdsvkqUJAA
165
165
  langtrace_python_sdk/instrumentation/ollama/patch.py,sha256=7ETx0tQic5h_kH1f-IeptFwgNTBb4hSkTkWsB18Avm0,5375
166
166
  langtrace_python_sdk/instrumentation/openai/__init__.py,sha256=VPHRNCQEdkizIVP2d0Uw_a7t8XOTSTprEIB8oboJFbs,95
167
167
  langtrace_python_sdk/instrumentation/openai/instrumentation.py,sha256=PZxI0qfoud1VsKGmJu49YDp0Z9z9TzCR8qxR3uznOMA,2810
168
- langtrace_python_sdk/instrumentation/openai/patch.py,sha256=qM8u2JUDHml5zFYEw7-i_cAweBu_DPsO7X5Yl1xPo5E,23756
168
+ langtrace_python_sdk/instrumentation/openai/patch.py,sha256=gW-3fUA-W4d9ADRYgNE_Nh6vijIS252J99Ato0OvunY,24246
169
169
  langtrace_python_sdk/instrumentation/openai/types.py,sha256=aVkoa7tmAbYfyOhnyMrDaVjQuwhmRNLMthlNtKMtWX8,4311
170
170
  langtrace_python_sdk/instrumentation/pinecone/__init__.py,sha256=DzXyGh9_MGWveJvXULkFwdkf7PbG2s3bAWtT1Dmz7Ok,99
171
171
  langtrace_python_sdk/instrumentation/pinecone/instrumentation.py,sha256=HDXkRITrVPwdQEoOYJOfMzZE_2-vDDvuqHTlD8W1lQw,1845
@@ -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.14.dist-info/METADATA,sha256=nhW-bRxBdnutDeBV01jGWuJ6IdWhe0sreHYqUJRW1cc,15380
235
- langtrace_python_sdk-2.3.14.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
236
- langtrace_python_sdk-2.3.14.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
237
- langtrace_python_sdk-2.3.14.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
238
- langtrace_python_sdk-2.3.14.dist-info/RECORD,,
234
+ langtrace_python_sdk-2.3.15.dist-info/METADATA,sha256=2O9NhKDhjCDa2lyBgB3xuuviMV2EJmaRziKQo11nEmk,15380
235
+ langtrace_python_sdk-2.3.15.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
236
+ langtrace_python_sdk-2.3.15.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
237
+ langtrace_python_sdk-2.3.15.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
238
+ langtrace_python_sdk-2.3.15.dist-info/RECORD,,