From the course: Secure Generative AI with Amazon Bedrock

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Integrating FMs into your code with Amazon Bedrock (Demo)

Integrating FMs into your code with Amazon Bedrock (Demo)

From the course: Secure Generative AI with Amazon Bedrock

Integrating FMs into your code with Amazon Bedrock (Demo)

- Alright, now let's see how to integrate foundation models into your code using Amazon Bedrock. So here I have pre-created this script to integrate foundation models in the code and it is available on GitHub with name bedrock.py. So here, first of all, I'm importing boto3 and Json, and please remember for this you need to install latest version of boto3, because that supports bedrock runtime. Then I'm simply creating an input where I am providing my API call. And this API call, I have simply grabbed from the dashboard. So here I'm using the cohere model. So if we go to the Amazon console, if you go to the providers tab here and go to the specific model provider, go here in this case, you can simply see there is an API request call is available. Just simply copy this code and paste it on your script. So here I have simply copied this, you can see the model ID here is cohere and then I have provided a prompt here. So I have simply provided a prompt here that please write a four liner…

Contents