Published on November 27, 2023, 5:51 am
Today, we are excited to announce two new optimized integrations for AWS Step Functions with Amazon Bedrock. If you’re not familiar, Step Functions is a visual workflow service designed to simplify the process of building distributed applications, automating tasks, orchestrating microservices, and creating data and machine learning (ML) pipelines.
Back in September, we introduced Amazon Bedrock, which quickly became the go-to solution for building and scaling generative artificial intelligence (AI) applications with foundation models (FMs). This groundbreaking offering provides customers with a range of foundation models from top providers like AI21 Labs, Anthropic, Cohere, Stability AI, and Amazon. It also includes powerful capabilities required to develop generative AI applications while ensuring privacy and security.
The integration between Step Functions and Amazon Bedrock has just gotten even better. These new integrations allow you to seamlessly orchestrate tasks when building generative AI applications using Amazon Bedrock. Additionally, you can easily integrate these workflows with over 220 other AWS services. With Step Functions’ intuitive interface, you can visually develop your workflows while having the ability to inspect and audit them as needed.
Previously, if you wanted to use Amazon Bedrock within your workflows, you had to invoke an AWS Lambda function. This added more code maintenance overhead and increased application costs. Fortunately, Step Functions now offers two new optimized API actions specifically for Amazon Bedrock that streamline this entire process.
The first API action is called “InvokeModel.” It allows you to send requests and receive responses up to 25 MB in size. However, it’s worth noting that there is a 256 kB limit on state payload input and output in Step Functions. To work around this limitation when using the integration with Amazon Bedrock, you can define an Amazon Simple Storage Service (Amazon S3) bucket where the InvokeModel API reads data from and writes results to.
Configuring these settings is straightforward through the parameters section of the API action configuration. This allows you to define the necessary configurations and ensure seamless integration with Amazon Bedrock.
Now, let’s explore how you can get started with Amazon Bedrock and AWS Step Functions:
1. Make sure you create your state machine in a region where Amazon Bedrock is available, such as US East (N. Virginia), us-east-1.
2. From the AWS Management Console, create a new state machine.
3. Search for “bedrock” to find the two available API actions related to Amazon Bedrock.
4. Drag and drop the “InvokeModel” action into your state machine workflow.
5. Configure the model settings by selecting which foundation model you want to utilize from the provided list or dynamically retrieve it from input data.
6. Set up the model parameters either by entering them directly or loading them from an Amazon S3 bucket.
7. Scroll through the API action configuration to specify additional options like the desired S3 destination bucket for storing API responses and content type for requests and responses.
Once you have finished configuring your state machine, you’re ready to create and run it. As your state machine runs, you can easily visualize its execution details, select specific states associated with Amazon Bedrock, and inspect their inputs and outputs.
The power of Step Functions lies in its versatility. You can build extensive state machines that combine various services to solve complex problems. For example, when using Step Functions alongside Amazon Bedrock, you can leverage a technique called prompt chaining to develop intricate generative AI applications.
Prompt chaining involves passing multiple smaller prompts to the FM instead of using one lengthy and detailed prompt. With Step Functions, you can create a state machine that calls Amazon Bedrock multiple times to generate inferences for each of these smaller prompts concurrently using parallel states. You can then use an AWS Lambda function to unify these parallel task responses into a single output result.
It’s important to note that the availability of AWS Step Functions optimized integrations for Amazon Bedrock is currently limited to regions where Amazon Bedrock is available.
If you’re eager to get started with Step Functions and Amazon Bedrock, we recommend trying out a sample project directly from the Step Functions console. This will give you hands-on experience and help you familiarize yourself with the powerful capabilities of these two services.
In conclusion, the new optimized integrations between AWS Step Functions and Amazon Bedrock deliver a seamless workflow orchestration experience for building generative AI applications. The enhanced integration eliminates the need for invoking AWS Lambda functions, reducing code complexity and streamlining application development. With the simplicity and power of Step Functions combined with the scalability and flexibility of Amazon Bedrock, developers have access to a comprehensive suite of tools to unleash their creativity in the world of generative AI.
Marcia Villalba is a Principal Developer Advocate for Amazon Web Services with over 20 years of experience in building and scaling applications. Her passion lies in designing systems that fully leverage cloud technologies while embracing a DevOps culture.