langtrace-python-sdk 3.8.17__py3-none-any.whl → 3.8.18__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,3 +1,4 @@
1
+ import base64
1
2
  from langtrace_python_sdk.utils.llm import (
2
3
  get_langtrace_attributes,
3
4
  get_llm_request_attributes,
@@ -14,20 +15,65 @@ from langtrace.trace_attributes import SpanAttributes
14
15
 
15
16
  from typing import Iterator
16
17
 
18
+ def capture_input_data(contents):
19
+ input_data = []
20
+
21
+ if isinstance(contents, list):
22
+ content_parts = []
23
+ for content in contents:
24
+ if hasattr(content, 'parts'):
25
+ for part in content.parts:
26
+ if hasattr(part, 'text') and part.text:
27
+ content_parts.append({
28
+ "type": "text",
29
+ "text": part.text
30
+ })
31
+ if hasattr(part, 'inline_data') and part.inline_data:
32
+ content_parts.append({
33
+ "type": "image_url",
34
+ "image_url": f"data:{part.inline_data.mime_type};base64,{base64.b64encode(part.inline_data.data).decode('utf-8')}"
35
+ })
36
+ else:
37
+ if isinstance(content, str):
38
+ content_parts.append({
39
+ "type": "text",
40
+ "text": content
41
+ })
42
+ elif hasattr(content, 'text') and content.text:
43
+ content_parts.append({
44
+ "type": "text",
45
+ "text": content.text
46
+ })
47
+ elif hasattr(content, 'inline_data') and content.inline_data:
48
+ content_parts.append({
49
+ "type": "image_url",
50
+ "image_url": f"data:{content.inline_data.mime_type};base64,{base64.b64encode(content.inline_data.data).decode('utf-8')}"
51
+ })
52
+ else:
53
+ content_parts.append({
54
+ "type": "text",
55
+ "text": content
56
+ })
57
+ input_data.append({
58
+ "role": "user",
59
+ "content": content_parts
60
+ })
61
+ else:
62
+ input_data.append({
63
+ "role": "user",
64
+ "content": contents
65
+ })
66
+
67
+ return input_data
68
+
17
69
 
18
70
  def patch_google_genai(tracer: Tracer, version: str):
19
71
  def traced_method(wrapped, instance, args, kwargs):
20
- prompt = [
21
- {
22
- "role": "user",
23
- "content": kwargs["contents"],
24
- }
25
- ]
26
72
  span_attributes = {
27
73
  **get_langtrace_attributes(
28
74
  service_provider="google_genai", version=version
29
75
  ),
30
- **get_llm_request_attributes(kwargs=kwargs, prompts=prompt),
76
+ **get_llm_request_attributes(kwargs=kwargs, prompts=capture_input_data(kwargs["contents"])),
31
77
  }
32
78
  with tracer.start_as_current_span(
33
79
  name="google.genai.generate_content",
@@ -1 +1 @@
1
- __version__ = "3.8.17"
1
+ __version__ = "3.8.18"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langtrace-python-sdk
3
- Version: 3.8.17
3
+ Version: 3.8.18
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>
@@ -10,7 +10,7 @@ Classifier: License :: OSI Approved :: Apache Software License
10
10
  Classifier: Operating System :: OS Independent
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Requires-Python: >=3.9
13
- Requires-Dist: boto3
13
+ Requires-Dist: boto3==1.38.0
14
14
  Requires-Dist: colorama>=0.4.6
15
15
  Requires-Dist: fsspec>=2024.6.0
16
16
  Requires-Dist: opentelemetry-api>=1.25.0
@@ -121,7 +121,7 @@ examples/weaviate_example/__init__.py,sha256=8JMDBsRSEV10HfTd-YC7xb4txBjD3la56sn
121
121
  examples/weaviate_example/query_text.py,sha256=wPHQTc_58kPoKTZMygVjTj-2ZcdrIuaausJfMxNQnQc,127162
122
122
  langtrace_python_sdk/__init__.py,sha256=VZM6i71NR7pBQK6XvJWRelknuTYUhqwqE7PlicKa5Wg,1166
123
123
  langtrace_python_sdk/langtrace.py,sha256=JYBCbklWv463lzRUH7pfkHAVoc3YHh-q_2Iv6LZ2HhU,14896
124
- langtrace_python_sdk/version.py,sha256=csVUBgURmjY_-YGxUIC12qiRsv-dOi-b_wDRDkd1SUg,23
124
+ langtrace_python_sdk/version.py,sha256=whHLu8P7QnGYdLeAzZ-eOHwlW3MJuanQ-a9U15xrJzY,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
@@ -192,7 +192,7 @@ langtrace_python_sdk/instrumentation/gemini/instrumentation.py,sha256=eGWr2dy1f_
192
192
  langtrace_python_sdk/instrumentation/gemini/patch.py,sha256=PG5E5v253x2ufQ81-aUUFzDRYq-DDhiqwmNoplHPjsM,6261
193
193
  langtrace_python_sdk/instrumentation/google_genai/__init__.py,sha256=nQ2kSsUDpLGZ_kz2QGddDwnawL9juVA7pW4G-BOe5VI,98
194
194
  langtrace_python_sdk/instrumentation/google_genai/instrumentation.py,sha256=rSB3nOXXe4gMVPWMGPnIHvWjqyPeRvifxOI62ulJ7uY,1049
195
- langtrace_python_sdk/instrumentation/google_genai/patch.py,sha256=X0TWY1D4XHweaNu70PlXBDzKEaHIibLpkJiIsp4jF6A,4115
195
+ langtrace_python_sdk/instrumentation/google_genai/patch.py,sha256=WS7VLe5lbbTU0BAiP69vJ5V5plyQ4GeXs1LQDBNqINQ,5995
196
196
  langtrace_python_sdk/instrumentation/graphlit/__init__.py,sha256=mkUPwozR-I-D5ZrumJs1gS7sSouY0UN68Ne9LiNEBTs,92
197
197
  langtrace_python_sdk/instrumentation/graphlit/instrumentation.py,sha256=V9GRZ6cj2lt20xCVfL55lGU4p0HlZxAYUqwpWogXDtY,2074
198
198
  langtrace_python_sdk/instrumentation/graphlit/patch.py,sha256=jVME4xlFTwJRPWOBGUtQiZrGkr1ScR2DSYwcWPd5smk,2921
@@ -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.17.dist-info/METADATA,sha256=feYBeHSHTLTW9hBTvwQxD52bd1Q2eeSpd-8un4fg5Y0,15845
316
- langtrace_python_sdk-3.8.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
317
- langtrace_python_sdk-3.8.17.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
318
- langtrace_python_sdk-3.8.17.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
319
- langtrace_python_sdk-3.8.17.dist-info/RECORD,,
315
+ langtrace_python_sdk-3.8.18.dist-info/METADATA,sha256=XHSAwzWsHAh5FLLWZ9896hei2d_hqQeEkomYDIEV0KM,15853
316
+ langtrace_python_sdk-3.8.18.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
317
+ langtrace_python_sdk-3.8.18.dist-info/entry_points.txt,sha256=1_b9-qvf2fE7uQNZcbUei9vLpFZBbbh9LrtGw95ssAo,70
318
+ langtrace_python_sdk-3.8.18.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
319
+ langtrace_python_sdk-3.8.18.dist-info/RECORD,,