Recently, I got curious about how easy it is nowadays to build an AI-powered app. So, I decided to give it a shot and was blown away by how easy and fast it was. Given some recent AWSome pre:Invent announcements, I saw that the Amplify team released an Amplify AI Kit for developers to build full-stack, AI-powered apps. So, I followed the tutorial in the AWS documentation for a recipe assistant.
After approximately 40 minutes of implementing the tutorial (I like to read first and type the code instead of copy/pasting), I already had a simple POC ready, with authentication, somewhat nice views, and inference for creating cooking recipes!
I added a couple of selects with options for the user to generate different kinds of stories:
After that, I changed the definition of the amplify data’s resources, which defines the cloud resources that will be used. So three things mainly changed: the arguments, returns, and the system prompt:
const schema = a.schema({
generateShortStory: a.generation({
aiModel: a.ai.model('Claude 3.5 Sonnet'),
systemPrompt: "You are a story-teller that generates short, engaging stories based on user-provided themes or genres. Each story should have a clear structure: an introduction to set the stage, a middle to develop the plot, a twist to surprise the reader, and a satisfying ending. The characters should be fictional, with at least one relatable protagonist. Adapt the tone and style based on user input. Ensure the story is concise and self-contained.",
})
.arguments({
genre: a.string(),
tone: a.string(),
style: a.string(),
})
.returns(
a.customType({
numberOfParagraphs: a.integer(),
story: a.string(),
})
)
.authorization((allow) => allow.authenticated()),
});
After making this change and saving, while still having the amplify sandbox environment active (npx ampx sandbox), the cloud resources will compile and resources will be updated to reflect these changes!
When inspecting in the AWS console about what resources are spun up, we realize it’s some awesome AWS serverless infrastructure that’s powering this AI kit. So apps created with this AI kit are ready to power your web apps and scale as easily as a serverless stack allows.
Here's an image of the general architecture of apps created using the aws amplify’s AI kit:
For my simple POC app, which only uses the “generate” variant of the kit (no conversation), I discovered that the stack is a bit different. It doesn’t use DynamoDB or Lambda, instead, AWS AppSync makes a direct HTTP request to Bedrock, and the mapping template from AppSync does the logic of formatting the response properly.
Here’s an image that shows the architecture of the short-story teller app created in this blog post using aws amplify’s generation AI kit:
This experiment showed me just how far tools like AWS Amplify and Bedrock have come. In just a few hours, I could get my app from idea to working proof-of-concept. The best part is that it’s backed by a scalable and efficient serverless infrastructure.