-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Description
Currently, AWSBedrockInstrumentation patches this properly
client = boto3.client("bedrock-runtime")However, LangChain initializes it a little different, like this:
session = boto3.Session()
client = session.client("bedrock-runtime")I think this change will fix it in manual testing, but need second eyes in case I goofed
--- a/src/langtrace_python_sdk/instrumentation/aws_bedrock/instrumentation.py
+++ b/src/langtrace_python_sdk/instrumentation/aws_bedrock/instrumentation.py
@@ -42,6 +42,11 @@ class AWSBedrockInstrumentation(BaseInstrumentor):
name="client",
wrapper=patch_aws_bedrock(tracer, version),
)
+ _W(
+ module="boto3.session",
+ name="Session.client",
+ wrapper=patch_aws_bedrock(tracer, version),
+ )
def _uninstrument(self, **kwargs):
passOnce this works, we can resolve langtrace usage inside Elastic chatbot-rag-app here, by removing a workaround:
--- a/example-apps/chatbot-rag-app/api/llm_integrations.py
+++ b/example-apps/chatbot-rag-app/api/llm_integrations.py
@@ -1,6 +1,5 @@
import os
-import boto3
from langchain_aws import ChatBedrock
from langchain_cohere import ChatCohere
from langchain_google_vertexai import ChatVertexAI
@@ -42,7 +41,6 @@ def init_bedrock(temperature):
AWSBedrockInstrumentation().instrument()
return ChatBedrock(
- client=boto3.client("bedrock-runtime"),
model_id=os.getenv("CHAT_MODEL"),
streaming=True,
model_kwargs={"temperature": temperature},Metadata
Metadata
Assignees
Labels
No labels