aws-samples/amazon-bedrock-serverless-prompt-chaining

Build complex, serverless, and highly scalable generative AI applications with prompt chaining.

What it solves

This project provides a framework and examples for building complex generative AI applications using prompt chaining. It solves the problem of handling complex tasks that are too large for a single LLM prompt by breaking them down into smaller, manageable subtasks that are executed in a specific order or according to defined rules.

How it works

The project demonstrates how to implement prompt chaining using two serverless AWS services:

  • AWS Step Functions: Orchestrates workflows using state machines that can include loops, parallel jobs, conditions, and integrations with over 220 AWS services and custom Lambda functions.
  • Amazon Bedrock Flows: A purpose-built tool for generative AI workflows that can iterate over arrays, invoke Bedrock agents, and retrieve data from Bedrock knowledge bases.

Both methods allow for techniques like prompt templating (injecting user input), sequential chaining (passing the output of one prompt to the next), and parallel chaining (running multiple prompts simultaneously and merging their results).

Who it’s for

Developers and architects building scalable, serverless AI applications on AWS who want to move beyond single-prompt interactions to complex, multi-step AI workflows.

Highlights

  • Serverless Architecture: No infrastructure management required for deployment or scaling.
  • Flexible Orchestration: Supports sequential, parallel, and map-based chains.
  • Linguistic Logic: Includes support for conditional branching and human-in-the-loop input.
  • Practical Examples: Provides templates for diverse use cases such as writing blog posts, planning trips, and pitching movie ideas.

Related

  • Project
  • Project
  • Project
  • Project
  • Project