invoke model errors / 00_generate_w_bedrock.ipynb
AttributeError Traceback (most recent call last) Cell In[21], line 8 4 outputText = "\n" 6 try: ----> 8 response = boto3_bedrock.invoke_model(body=body, modelId=modelId, accept=accept, contentType=contentType) 9 response_body = json.loads(response.get("body").read()) 11 outputText = response_body.get('results')[0].get('outputText')
File /opt/conda/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_model'
are you running the workshop in SageMaker studio? if so, you need to add the bedrock permissions to the SageMaker execution role. If you are running in your own laptop, ensure your user/role has the right permissions by updating the code in the first cell.
Make sure to set runtime= True in the setup script and try to run the commands which involve Invoke operations
boto3_bedrock = bedrock.get_bedrock_client( assumed_role=os.environ.get("BEDROCK_ASSUME_ROLE", None), region=os.environ.get("AWS_DEFAULT_REGION", None), runtime=False )
Closing this; please refer to the latest bedrock workshop update and reopen if still relevant