langtrace-python-sdk 3.8.10__py3-none-any.whl → 3.8.11__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.
- langtrace_python_sdk/instrumentation/cohere/patch.py +62 -59
- langtrace_python_sdk/instrumentation/openai/patch.py +4 -1
- langtrace_python_sdk/langtrace.py +2 -1
- langtrace_python_sdk/utils/llm.py +3 -3
- langtrace_python_sdk/version.py +1 -1
- {langtrace_python_sdk-3.8.10.dist-info → langtrace_python_sdk-3.8.11.dist-info}/METADATA +1 -1
- {langtrace_python_sdk-3.8.10.dist-info → langtrace_python_sdk-3.8.11.dist-info}/RECORD +10 -10
- {langtrace_python_sdk-3.8.10.dist-info → langtrace_python_sdk-3.8.11.dist-info}/WHEEL +0 -0
- {langtrace_python_sdk-3.8.10.dist-info → langtrace_python_sdk-3.8.11.dist-info}/entry_points.txt +0 -0
- {langtrace_python_sdk-3.8.10.dist-info → langtrace_python_sdk-3.8.11.dist-info}/licenses/LICENSE +0 -0
@@ -87,25 +87,25 @@ def rerank(original_method, version, tracer, v2=False):
|
|
87
87
|
and result.meta.billed_units is not None
|
88
88
|
):
|
89
89
|
usage = result.meta.billed_units
|
90
|
-
if usage
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
90
|
+
input_tokens = int(usage.input_tokens) if usage.input_tokens else 0
|
91
|
+
output_tokens = int(usage.output_tokens) if usage.output_tokens else 0
|
92
|
+
span.set_attribute(
|
93
|
+
SpanAttributes.LLM_USAGE_PROMPT_TOKENS,
|
94
|
+
input_tokens,
|
95
|
+
)
|
96
|
+
span.set_attribute(
|
97
|
+
SpanAttributes.LLM_USAGE_COMPLETION_TOKENS,
|
98
|
+
output_tokens,
|
99
|
+
)
|
100
|
+
span.set_attribute(
|
101
|
+
SpanAttributes.LLM_USAGE_TOTAL_TOKENS,
|
102
|
+
input_tokens + output_tokens,
|
103
|
+
)
|
104
|
+
span.set_attribute(
|
105
|
+
"search_units",
|
106
|
+
int(usage.search_units) if usage.search_units else 0,
|
107
|
+
)
|
108
|
+
|
109
109
|
|
110
110
|
span.set_status(StatusCode.OK)
|
111
111
|
span.end()
|
@@ -309,25 +309,25 @@ def chat_create(original_method, version, tracer):
|
|
309
309
|
and result.meta.billed_units is not None
|
310
310
|
):
|
311
311
|
usage = result.meta.billed_units
|
312
|
-
if usage
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
312
|
+
input_tokens = int(usage.input_tokens) if usage.input_tokens else 0
|
313
|
+
output_tokens = int(usage.output_tokens) if usage.output_tokens else 0
|
314
|
+
span.set_attribute(
|
315
|
+
SpanAttributes.LLM_USAGE_PROMPT_TOKENS,
|
316
|
+
input_tokens,
|
317
|
+
)
|
318
|
+
span.set_attribute(
|
319
|
+
SpanAttributes.LLM_USAGE_COMPLETION_TOKENS,
|
320
|
+
output_tokens,
|
321
|
+
)
|
322
|
+
span.set_attribute(
|
323
|
+
SpanAttributes.LLM_USAGE_TOTAL_TOKENS,
|
324
|
+
input_tokens + output_tokens,
|
325
|
+
)
|
326
|
+
span.set_attribute(
|
327
|
+
"search_units",
|
328
|
+
int(usage.search_units) if usage.search_units else 0,
|
329
|
+
)
|
330
|
+
|
331
331
|
span.set_status(StatusCode.OK)
|
332
332
|
span.end()
|
333
333
|
return result
|
@@ -419,10 +419,12 @@ def chat_create_v2(original_method, version, tracer, stream=False):
|
|
419
419
|
if (hasattr(result.usage, "billed_units") and
|
420
420
|
result.usage.billed_units is not None):
|
421
421
|
usage = result.usage.billed_units
|
422
|
+
input_tokens = int(usage.input_tokens) if usage.input_tokens else 0
|
423
|
+
output_tokens = int(usage.output_tokens) if usage.output_tokens else 0
|
422
424
|
for metric, value in {
|
423
|
-
"input":
|
424
|
-
"output":
|
425
|
-
"total":
|
425
|
+
"input": input_tokens,
|
426
|
+
"output": output_tokens,
|
427
|
+
"total": input_tokens + output_tokens,
|
426
428
|
}.items():
|
427
429
|
span.set_attribute(
|
428
430
|
f"gen_ai.usage.{metric}_tokens",
|
@@ -571,26 +573,27 @@ def chat_stream(original_method, version, tracer):
|
|
571
573
|
and response.meta.billed_units is not None
|
572
574
|
):
|
573
575
|
usage = response.meta.billed_units
|
574
|
-
if usage
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
576
|
+
input_tokens = int(usage.input_tokens) if usage.input_tokens else 0
|
577
|
+
output_tokens = int(usage.output_tokens) if usage.output_tokens else 0
|
578
|
+
span.set_attribute(
|
579
|
+
SpanAttributes.LLM_USAGE_PROMPT_TOKENS,
|
580
|
+
input_tokens,
|
581
|
+
)
|
582
|
+
span.set_attribute(
|
583
|
+
SpanAttributes.LLM_USAGE_COMPLETION_TOKENS,
|
584
|
+
output_tokens,
|
585
|
+
)
|
586
|
+
span.set_attribute(
|
587
|
+
SpanAttributes.LLM_USAGE_TOTAL_TOKENS,
|
588
|
+
input_tokens + output_tokens,
|
589
|
+
)
|
590
|
+
|
591
|
+
if usage.search_units is not None:
|
584
592
|
span.set_attribute(
|
585
|
-
|
586
|
-
(usage.
|
587
|
-
+ (usage.output_tokens or 0),
|
593
|
+
"search_units",
|
594
|
+
int(usage.search_units) if usage.search_units else 0,
|
588
595
|
)
|
589
|
-
|
590
|
-
span.set_attribute(
|
591
|
-
"search_units",
|
592
|
-
usage.search_units or 0,
|
593
|
-
)
|
596
|
+
|
594
597
|
|
595
598
|
yield event
|
596
599
|
finally:
|
@@ -114,6 +114,9 @@ def openai_responses_create(version: str, tracer: Tracer) -> Callable:
|
|
114
114
|
return StreamWrapper(response, span)
|
115
115
|
else:
|
116
116
|
_set_openai_agentic_response_attributes(span, response)
|
117
|
+
|
118
|
+
span.set_status(StatusCode.OK)
|
119
|
+
span.end()
|
117
120
|
return response
|
118
121
|
except Exception as err:
|
119
122
|
span.record_exception(err)
|
@@ -738,7 +741,7 @@ def _set_openai_agentic_response_attributes(span: Span, response) -> None:
|
|
738
741
|
"input_tokens": response.usage.input_tokens,
|
739
742
|
"output_tokens": response.usage.output_tokens,
|
740
743
|
"total_tokens": response.usage.total_tokens,
|
741
|
-
"cached_tokens": response.usage.input_tokens_details
|
744
|
+
"cached_tokens": response.usage.input_tokens_details.cached_tokens,
|
742
745
|
},
|
743
746
|
)
|
744
747
|
|
@@ -299,7 +299,8 @@ def init(
|
|
299
299
|
init_instrumentations(config.disable_instrumentations, all_instrumentations)
|
300
300
|
add_span_processor(provider, config, exporter)
|
301
301
|
|
302
|
-
|
302
|
+
if config.disable_logging:
|
303
|
+
sys.stdout = sys.__stdout__
|
303
304
|
init_sentry(config, host)
|
304
305
|
|
305
306
|
|
@@ -347,19 +347,19 @@ def set_usage_attributes(span, usage):
|
|
347
347
|
set_span_attribute(
|
348
348
|
span,
|
349
349
|
SpanAttributes.LLM_USAGE_PROMPT_TOKENS,
|
350
|
-
input_tokens,
|
350
|
+
int(input_tokens),
|
351
351
|
)
|
352
352
|
|
353
353
|
set_span_attribute(
|
354
354
|
span,
|
355
355
|
SpanAttributes.LLM_USAGE_COMPLETION_TOKENS,
|
356
|
-
output_tokens,
|
356
|
+
int(output_tokens),
|
357
357
|
)
|
358
358
|
|
359
359
|
set_span_attribute(
|
360
360
|
span,
|
361
361
|
SpanAttributes.LLM_USAGE_TOTAL_TOKENS,
|
362
|
-
input_tokens + output_tokens,
|
362
|
+
int(input_tokens) + int(output_tokens),
|
363
363
|
)
|
364
364
|
|
365
365
|
if "search_units" in usage:
|
langtrace_python_sdk/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "3.8.
|
1
|
+
__version__ = "3.8.11"
|
@@ -120,8 +120,8 @@ examples/vertexai_example/main.py,sha256=gndId5X5ksD-ycxnAWMdEqIDbLc3kz5Vt8vm4YP
|
|
120
120
|
examples/weaviate_example/__init__.py,sha256=8JMDBsRSEV10HfTd-YC7xb4txBjD3la56snk-Bbg2Kw,618
|
121
121
|
examples/weaviate_example/query_text.py,sha256=wPHQTc_58kPoKTZMygVjTj-2ZcdrIuaausJfMxNQnQc,127162
|
122
122
|
langtrace_python_sdk/__init__.py,sha256=VZM6i71NR7pBQK6XvJWRelknuTYUhqwqE7PlicKa5Wg,1166
|
123
|
-
langtrace_python_sdk/langtrace.py,sha256=
|
124
|
-
langtrace_python_sdk/version.py,sha256=
|
123
|
+
langtrace_python_sdk/langtrace.py,sha256=mTCx5nyBbXNINr0oVWvMZ9iU47MWhRg2DBel2gwlnLg,13979
|
124
|
+
langtrace_python_sdk/version.py,sha256=SOTowMrQm37hhBSrXviQdSFjTgt0PPZQX6q3WhiUwNY,23
|
125
125
|
langtrace_python_sdk/constants/__init__.py,sha256=3CNYkWMdd1DrkGqzLUgNZXjdAlM6UFMlf_F-odAToyc,146
|
126
126
|
langtrace_python_sdk/constants/exporter/langtrace_exporter.py,sha256=EVCrouYCpY98f0KSaKr4PzNxPULTZZO6dSA_crEOyJU,106
|
127
127
|
langtrace_python_sdk/constants/instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -174,7 +174,7 @@ langtrace_python_sdk/instrumentation/cleanlab/instrumentation.py,sha256=CtWdtDUC
|
|
174
174
|
langtrace_python_sdk/instrumentation/cleanlab/patch.py,sha256=aI0QfG9UH5P7OvmzeIdeMhRd28oV4JMuXIkPv8s869s,3138
|
175
175
|
langtrace_python_sdk/instrumentation/cohere/__init__.py,sha256=sGUSLdTUyYf36Tm6L5jQflhzCqvmWrhnBOMYHjvp6Hs,95
|
176
176
|
langtrace_python_sdk/instrumentation/cohere/instrumentation.py,sha256=1wxMhWMfsvKprdV52BIfCZhZS1beRYBW9rUzUDDkyCk,2854
|
177
|
-
langtrace_python_sdk/instrumentation/cohere/patch.py,sha256=
|
177
|
+
langtrace_python_sdk/instrumentation/cohere/patch.py,sha256=qeXm4ycnXfDO7lxWrpA2GaUIvGTkLcSMiq9-xMtlP6U,25782
|
178
178
|
langtrace_python_sdk/instrumentation/crewai/__init__.py,sha256=_UBKfvQv7l0g2_wnmA5F6CdSAFH0atNOVPd49zsN3aM,88
|
179
179
|
langtrace_python_sdk/instrumentation/crewai/instrumentation.py,sha256=5Umzq8zjEnMEtjZZiMB4DQOPkxZ-1vts7RKC6JWpn24,2969
|
180
180
|
langtrace_python_sdk/instrumentation/crewai/patch.py,sha256=VoyOtGKYzaOIu7UnVNTemZeB3LrCIodrrYwmXLdxRw8,9133
|
@@ -235,7 +235,7 @@ langtrace_python_sdk/instrumentation/ollama/instrumentation.py,sha256=jdsvkqUJAA
|
|
235
235
|
langtrace_python_sdk/instrumentation/ollama/patch.py,sha256=w99r9wCCVDdJnZQEezYE2lW_iNFEtrldt9vq3ISAsag,5375
|
236
236
|
langtrace_python_sdk/instrumentation/openai/__init__.py,sha256=VPHRNCQEdkizIVP2d0Uw_a7t8XOTSTprEIB8oboJFbs,95
|
237
237
|
langtrace_python_sdk/instrumentation/openai/instrumentation.py,sha256=kvbRr5DrcP23ka4mLZpwr7W0ZxeTGHilkOlc_h5V5s8,3226
|
238
|
-
langtrace_python_sdk/instrumentation/openai/patch.py,sha256=
|
238
|
+
langtrace_python_sdk/instrumentation/openai/patch.py,sha256=o3OB8UfZr6kZo2uBfbXsTRyuv1vWBAsRlcB3DRcjN6s,31450
|
239
239
|
langtrace_python_sdk/instrumentation/openai/types.py,sha256=aVkoa7tmAbYfyOhnyMrDaVjQuwhmRNLMthlNtKMtWX8,4311
|
240
240
|
langtrace_python_sdk/instrumentation/openai_agents/__init__.py,sha256=ElRfFIQYXD2-eRyL3fZnjIsDJLTrDolh5cZHPnZv0q8,107
|
241
241
|
langtrace_python_sdk/instrumentation/openai_agents/instrumentation.py,sha256=6M4FHXfem7pazrNgsimebrEfMb2FxI8lHrdEMbVf75Y,1860
|
@@ -261,7 +261,7 @@ langtrace_python_sdk/instrumentation/weaviate/patch.py,sha256=igqYUR_bEjs1XtyyZ8
|
|
261
261
|
langtrace_python_sdk/types/__init__.py,sha256=SJSJzkgPjGGTVJXUZ_FyR3p9DJ5kWGx7iAnJfY4ZYHU,4669
|
262
262
|
langtrace_python_sdk/utils/__init__.py,sha256=VVDOG-QLd59ZvSHp0avjof0sbxlZ1QQOf0KoOF7ofhQ,3310
|
263
263
|
langtrace_python_sdk/utils/langtrace_sampler.py,sha256=BupNndHbU9IL_wGleKetz8FdcveqHMBVz1bfKTTW80w,1753
|
264
|
-
langtrace_python_sdk/utils/llm.py,sha256=
|
264
|
+
langtrace_python_sdk/utils/llm.py,sha256=yhokm_xqisPLDwopKxqp9OHnmksTKtGanBmXvu3KaHQ,23445
|
265
265
|
langtrace_python_sdk/utils/misc.py,sha256=LaQr5LOmZMiuwVdjYh7aIu6o2C_Xb1wgpQGNOVmRzfE,1918
|
266
266
|
langtrace_python_sdk/utils/prompt_registry.py,sha256=n5dQMVLBw8aJZY8Utvf67bncc25ELf6AH9BYw8_hSzo,2619
|
267
267
|
langtrace_python_sdk/utils/sdk_version_checker.py,sha256=F-VVVH7Fmhr5LcY0IIe-34zIi5RQcx26uuxFpPzZesM,1782
|
@@ -312,8 +312,8 @@ tests/pinecone/cassettes/test_query.yaml,sha256=b5v9G3ssUy00oG63PlFUR3JErF2Js-5A
|
|
312
312
|
tests/pinecone/cassettes/test_upsert.yaml,sha256=neWmQ1v3d03V8WoLl8FoFeeCYImb8pxlJBWnFd_lITU,38607
|
313
313
|
tests/qdrant/conftest.py,sha256=9n0uHxxIjWk9fbYc4bx-uP8lSAgLBVx-cV9UjnsyCHM,381
|
314
314
|
tests/qdrant/test_qdrant.py,sha256=pzjAjVY2kmsmGfrI2Gs2xrolfuaNHz7l1fqGQCjp5_o,3353
|
315
|
-
langtrace_python_sdk-3.8.
|
316
|
-
langtrace_python_sdk-3.8.
|
317
|
-
langtrace_python_sdk-3.8.
|
318
|
-
langtrace_python_sdk-3.8.
|
319
|
-
langtrace_python_sdk-3.8.
|
315
|
+
langtrace_python_sdk-3.8.11.dist-info/METADATA,sha256=uthy1_AtXV7QgTGRDn_gOcXyZokYgF5_FU858iZeEbw,15845
|
316
|
+
langtrace_python_sdk-3.8.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
317
|
+
langtrace_python_sdk-3.8.11.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
|
318
|
+
langtrace_python_sdk-3.8.11.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
319
|
+
langtrace_python_sdk-3.8.11.dist-info/RECORD,,
|
File without changes
|
{langtrace_python_sdk-3.8.10.dist-info → langtrace_python_sdk-3.8.11.dist-info}/entry_points.txt
RENAMED
File without changes
|
{langtrace_python_sdk-3.8.10.dist-info → langtrace_python_sdk-3.8.11.dist-info}/licenses/LICENSE
RENAMED
File without changes
|