Calling AWS Bedrock from code. Using Python in a Jupyter notebook | by Thomas Reid | Oct, 2023

Image by Author

Using Python in a Jupyter notebook

Many of you will know that every man and his dog are producing AI products or LLM’s and integrating them with their products. Not surprisingly AWS — the biggest cloud services provider — is also getting in on the act.

What is bedrock?

Its AI offering is called Bedrock and the following blurb from it’s website describes what Bedrock is.

Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies like AI21 Labs, Anthropic, Cohere, Meta, Stability AI, and Amazon via a single API, along with a broad set of capabilities you need to build generative AI applications, simplifying development while maintaining privacy and security. With Amazon Bedrock’s comprehensive capabilities, you can easily experiment with a variety of top FMs, privately customize them with your data using techniques such as fine-tuning and retrieval augmented generation (RAG), and create managed agents that execute complex business tasks — from booking travel and processing insurance claims to creating ad campaigns and managing inventory — all without writing any code. Since Amazon Bedrock is serverless, you don’t have to manage any infrastructure, and you can securely integrate and deploy generative AI capabilities into your applications using the AWS services you are already familiar with.

Recently, AWS Bedrock became generally available (GA) in certain regions which means it’s now “safe” to use it in production systems in those regions. You can use Bedrock straight from the AWS console but I guess most organisations will want to call it from code. To that end, AWS has updated its version of Boto3 to include API calls to Bedrock. Boto3 is AWS’s Python library that allows you to access, use and call AWS services e.g S3, DynamoDB etc ….

So, if you want to use Python to access Bedrock you’ll need to upgrade your boto3 library to at least version 1.28.57

You can check out the latest boto3 documentation and get instructions for downloading it by clicking the link below.

Source link

2023. All Rights Reserved.