aws-samples / amazon-bedrock-workshop

This is a workshop designed for Amazon Bedrock a foundational model service.
https://catalog.us-east-1.prod.workshops.aws/workshops/a4bdb007-5600-4368-81c5-ff5b4154f518/en-US/20-intro
MIT No Attribution
1.39k stars 591 forks source link

langchain with bedrock client not works #79

Closed qingyuan18 closed 11 months ago

qingyuan18 commented 11 months ago

from langchain.llms import Bedrock

boto3_bedrock = boto3.client( service_name="bedrock", region_name="us-west-2", endpoint_url="https://bedrock.us-west-2.amazonaws.com", aws_access_key_id="**", aws_secret_access_key="****" )

parameters_bedrock = { "max_tokens_to_sample": 450,

"stop_sequences":STOP,

#"temperature":0.5,
# "top_p":0.9

}

berock_llm = Bedrock(model_id="anthropic.claude-v2", client=boto3_bedrock, model_kwargs=parameters_bedrock) #

berock_llm = Bedrock(model_id="anthropic.claude-v2",region_name="us-west-2",

endpoint_url="https://bedrock.us-west-2.amazonaws.com",

credentials_profile_name="default")

berock_llm("hi there")

---> 75 boto3_bedrock.invoke("hi there")

File ~/anaconda3/envs/pytorch_p310/lib/python3.10/site-packages/botocore/client.py:888, in BaseClient.getattr(self, item) 885 if event_response is not None: 886 return event_response --> 888 raise AttributeError( 889 f"'{self.class.name}' object has no attribute '{item}'" 890 )

AttributeError: 'Bedrock' object has no attribute 'invoke'

alkayahan commented 11 months ago

https://github.com/aws-samples/amazon-bedrock-workshop/issues/58

lauerarnaud commented 11 months ago

Please retest with latest version of repo and new SDK since Amazon Bedrock is now GA. Relevant PRs have been merged.