logo
Menu
Building NellyBot - How to use generative AI to become a better developer

Building NellyBot - How to use generative AI to become a better developer

How you can use Amazon Q Developer and Amazon Bedrock to help you speed up your development process.

Ana Cunha
Amazon Employee
Published Sep 3, 2024
Authors: Ana Cunha (ana.dev) & Jose Yapur (develozombie)
As we have shared in the previous episode, we started our generative AI journey with some doubts. Maybe this is just another technology hype that everyone wants to use? But here we are, excited and writing an article to share our experience. And we know that this content series is about how we created NellyBot, but before we even start thinking of using all these tools, let’s ask ourselves what are the boundaries of generative AI and where it can take us.
To do so, we will start with a simple use case: “Deploying a 3-layer AWS Architecture using generative AI without any biped mammal (i.e. human) intervention apart from an initial image of the architecture and the prompts”. We will see what works and what could be made by a human. We are calling this experiment “Reality Check”.
Now let’s start with the Step by Step!
  • To start things off, we have our initial architecture design:
Architecture design of the application
Architecture design
  • We then navigate to the AWS Console and go to Amazon Bedrock. Inside Amazon Bedrock, there are a lot of options that you can explore on your own. This time we are going to select “Chat” under “Playgrounds”. Once that is open, we are going to click on “Select model”.
Amazon Bedrock Chat Playground - Select model
Amazon Bedrock Playground
  • Here we can find many different models for different purposes. After a little bit of research, we learned that Claude is a great option for vision and text, so let’s go for it. Let’s select “Claude 3 Haiku”.
Amazon Bedrock Chat Playground - Select model
Selecting a model on Amazon Bedrock Playground
  • Now, we upload the image of our architecture and write instructions (that is, our prompt) in the chat. In this step, it is important to give much detail as possible on what you need and for what purpose. For example: “Write the description of the architecture represented in this image. Give me as much detail as possible so that I can use the generated description as a prompt for another Generative AI service to create the CDK code of the architecture”.
  • After some iterations chatting with the model, it should give you a description of the architecture that you are happy with. Make sure you save this description, as we are going to use it shortly. Remember that generative AI is non-deterministic, which means that your results will be slightly different every time, even if you are asking the model for the exact same thing.
  • For this project, we are going to code on VS Code using the TypeScript programming language. For the definition of our infrastructure, we will use AWS CDK. You will need the following VS Code extensions: 1/ Amazon Q and the 2/ AWS Toolkit.
  • For command-line assistance, we are going to use Amazon Q for command line (for now, only available for macOS users). If you are not a macOS user, don’t worry. We will include the required commands below.
  • Make sure you log in into your VS Code extensions and Amazon Q for command line before continuing. Now, let the magic happen!
  • Open your terminal and start chatting with Amazon Q. You can tell Q what you want to do by typing q translate “<Your question>”. Q will then suggest you a command that you can execute right away or make some changes before executing. It’s a developer’s dream come true, less time searching through the documentation and more time spent on real coding. We first ask Q to create a folder named “demo-nellybot”. It gives us the following command:
  • We go into the newly created folder by typing cd demo-nellybot/. And then we ask Q to initialize a new CDK project using TypeScript. Again, it gives us the following command:
  • From this point, we can open the generated CDK project in the demo-nellybot folder on VS Code and continue from there. On VS Code, we will use the chat on the Amazon Q Developer extension. We are going to ask Q Developer to generate the CDK infrastructure code for us. To do so, we will begin our request with /dev before our request. Here, we will ask Q to “Generate the infrastructure for the architecture described below using the current CDK project” and we will add the output generated by the Amazon Bedrock Playground that we had previously saved.
  • As soon as we finish with the previous steps we should have a fully working CDK project. You can also make changes to the generated code if necessary. We will ask Q in the command line to synthesize the CDK project into a CloudFormation template:
  • Once we are happy with our current infrastructure, let’s go ahead and deploy the CDK project. This will provision the infrastructure for our architecture:
  • If you get any errors during the process, you can chat with the Amazon Q VS Code extension to help you solve them.
AWS CDK Deployment successful
AWS CDK Deployment
So this was a quick tour of some of the tools we are going to use help us accelerate the development of our project. We are using Amazon Q Developer and Amazon Bedrock to help us become better developers, getting answers to our coding questions, and generating code that can be used for our projects.
In our experience, this was a great way to search for commands and generate code directly from our IDE, and things felt natural to us as developers. Keep in mind that the results can vary. We may have to iterate our requests (prompts) to get the answers we want, and the code generated might require modifications and tweaks. Developers experience and criteria is still required to make the best use of these tools.
During the next episodes we are going to continue exploring Gen AI tools, with specific focus on How to automate user requests using Agents with large language models (LLM) and Action Groups.
 

Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.

Comments