Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/examples/awsbedrock_examples/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from examples.awsbedrock_examples.converse import (
use_invoke_model_anthropic,
init_bedrock_langchain,
use_invoke_model_titan,
use_invoke_model_llama,
)
Expand All @@ -15,4 +16,5 @@ def run(self):
# use_invoke_model_anthropic(stream=True)
# use_invoke_model_cohere()
# use_invoke_model_llama(stream=False)
use_invoke_model_titan(stream=False)
# use_invoke_model_titan(stream=False)
init_bedrock_langchain()
11 changes: 11 additions & 0 deletions src/examples/awsbedrock_examples/converse.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from langtrace_python_sdk import langtrace
from dotenv import load_dotenv
import botocore
from langchain_aws import ChatBedrock

load_dotenv()
langtrace.init(write_spans_to_console=False)
Expand Down Expand Up @@ -186,3 +187,13 @@ def use_invoke_model_cohere():
response = brt.invoke_model(body=body, modelId=model_id)
response_body = json.loads(response.get("body").read())
print(response_body)


def init_bedrock_langchain(temperature=0.1):
chat = ChatBedrock(
model_id="anthropic.claude-v2",
streaming=True,
model_kwargs={"temperature": temperature},
region_name="us-east-1",
)
return chat.invoke("What is the capital of France?")
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ def _instrument(self, **kwargs):
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):
pass
2 changes: 1 addition & 1 deletion src/langtrace_python_sdk/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.3.25"
__version__ = "3.3.26"
Loading