Skip to content

Commit 39b2f52

Browse files
committed
Merge branch 'development' into release-3.8.19
2 parents 093c784 + cc95a5a commit 39b2f52

File tree

5 files changed

+64
-14
lines changed

5 files changed

+64
-14
lines changed

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ dependencies = [
3232
"transformers>=4.11.3",
3333
"sentry-sdk>=2.14.0",
3434
"ujson>=5.10.0",
35-
"boto3",
35+
"boto3==1.38.0",
3636
"setuptools",
37+
"Deprecated==1.2.18",
3738
]
3839

3940
requires-python = ">=3.9"
@@ -47,7 +48,7 @@ dev = [
4748
"qdrant-client",
4849
"graphlit-client",
4950
"python-dotenv",
50-
"pinecone",
51+
"pinecone>=3.1.0,<=6.0.2",
5152
"langchain",
5253
"langchain-community",
5354
"langchain-openai",

src/langtrace_python_sdk/instrumentation/aws_bedrock/patch.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import json
1818

1919
from wrapt import ObjectProxy
20+
from itertools import tee
2021
from .stream_body_wrapper import BufferedStreamBody
2122
from functools import wraps
2223
from langtrace.trace_attributes import (
@@ -128,7 +129,9 @@ def traced_method(*args, **kwargs):
128129
response = original_method(*args, **kwargs)
129130

130131
if span.is_recording():
131-
set_span_streaming_response(span, response)
132+
stream1, stream2 = tee(response["stream"])
133+
set_span_streaming_response(span, stream1)
134+
response["stream"] = stream2
132135
return response
133136

134137
return traced_method
@@ -442,10 +445,10 @@ def _set_response_attributes(span, kwargs, result):
442445
)
443446

444447

445-
def set_span_streaming_response(span, response):
448+
def set_span_streaming_response(span, response_stream):
446449
streaming_response = ""
447450
role = None
448-
for event in response["stream"]:
451+
for event in response_stream:
449452
if "messageStart" in event:
450453
role = event["messageStart"]["role"]
451454
elif "contentBlockDelta" in event:

src/langtrace_python_sdk/instrumentation/google_genai/patch.py

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import base64
12
from langtrace_python_sdk.utils.llm import (
23
get_langtrace_attributes,
34
get_llm_request_attributes,
@@ -14,20 +15,65 @@
1415

1516
from typing import Iterator
1617

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+
1769

1870
def patch_google_genai(tracer: Tracer, version: str):
1971
def traced_method(wrapped, instance, args, kwargs):
20-
prompt = [
21-
{
22-
"role": "user",
23-
"content": kwargs["contents"],
24-
}
25-
]
2672
span_attributes = {
2773
**get_langtrace_attributes(
2874
service_provider="google_genai", version=version
2975
),
30-
**get_llm_request_attributes(kwargs=kwargs, prompts=prompt),
76+
**get_llm_request_attributes(kwargs=kwargs, prompts=capture_input_data(kwargs["contents"])),
3177
}
3278
with tracer.start_as_current_span(
3379
name="google.genai.generate_content",

src/langtrace_python_sdk/instrumentation/pinecone/instrumentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class PineconeInstrumentation(BaseInstrumentor):
3333
The PineconeInstrumentation class represents the Pinecone instrumentation"""
3434

3535
def instrumentation_dependencies(self) -> Collection[str]:
36-
return ["pinecone >= 3.1.0"]
36+
return ["pinecone >= 3.1.0", "pinecone <= 6.0.2"]
3737

3838
def _instrument(self, **kwargs):
3939
tracer_provider = kwargs.get("tracer_provider")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.8.17"
1+
__version__ = "3.8.19"

0 commit comments

Comments
 (0)