Do you believe AI will replace your job?
Tags: amazonq, amazoncodewhisperer, aws, genai
Published: 2023-12-14 05:55:45

## Introduction

A few weeks ago, I chatted with a lady at the bus station. We both work in tech and share an interest in it. When we talked about our passion for technology, she asked, "Do you think AI will replace your job?". This question often arises in discussions about AI and ML. In my view, AI and ML won't replace us; they'll boost our abilities, making medical diagnoses more accurate, strengthening security, and improving overall work efficiency.

Am I worried about AI taking over my job after `AWS Re:Invent` last week, where they introduced services like [Amazon Q](https://aws.amazon.com/q/) and [Amazon CodeCatalyst](https://aws.amazon.com/codecatalyst/)?

Should I be concerned about my job as a Developer with these AI services? Let's explore together and learn more about them.

You probably know SST Framework and Svelte Kit – nothing groundbreaking. Despite not being an expert in Svelte and SST recently, I decided to experiment with these tools, combining SST and Svelte with Amazon Q and Amazon CodeWhisperer using the AWS Toolkit in the IDE.

In this blog post, I'll share my thoughts on this setup and how I found these services through the Amazon Toolkit. You'll also find out if we should be concerned about AI assistants taking over our jobs as Developers.

## An Introduction to Svelte, SST, Amazon Q and Amazon CodeWhisperer

Before diving into writing code and utilising various services from the Amazon Toolkit in VSCode, it's worth taking a quick look at what we're about to use, especially if you're not familiar with them.

### Svelte
[Svelte](https://svelte.dev/) is a JavaScript tool for constructing UI components, similar to other UI frameworks like React and Vue. However, what sets Svelte apart is that it functions as a compiler, transforming the code into a form compatible with native browser APIs.

### SST Framework

[SST](https://sst.dev/) is an open-source framework designed to facilitate the development and deployment of Serverless stacks on AWS. It operates under the hood by integrating with Amazon CDK. However, its primary benefit is in allowing us to concentrate on creating resources using familiar languages like TypeScript, treating them as Infrastructure as Code (IaC).

### Amazon Q

Imagine OpenAI's ChatGPT, Microsoft's Copilots, and now, Amazon has introduced its own AI assistant called [Amazon Q](https://aws.amazon.com/q/).

There are different ways we can use Amazon Q. You can connect it to your business data for a personalised touch to suit your specific nee
ds like a chatbot that is customised for your business.

It's also accessible within the AWS console as an expert who can give you suggestions on architecture and solution designs with best practices. Amazon Q seamlessly integrates with Amazon Insight. This integration assists with visualisations, data analysis, and answering any data-related questions you may have. More importantly, as a developer, you can leverage Amazon Q within your IDE for code improvements, debugging and troubleshooting. That's the use case I am going to focus on in this blog.

### Amazon CodeWhisperer

[CodeWhisperer](https://aws.amazon.com/codewhisperer/) is a GenAI-powered tool that assists with code recommendations based on Pseudocode or existing codes. It can be configured within your IDE or through the command line. Extending its capabilities, CodeWhisperer is compatible with certain AWS services, including [Amazon SageMaker Studio](https://docs.aws.amazon.com/codewhisperer/latest/userguide/sagemaker-setup.html) and [Amazon Glue Studio](https://docs.aws.amazon.com/codewhisperer/latest/userguide/glue-setup.html).

You can utilise Amazon CodeWhisperer at no cost by [configuring it within your IDE](https://aws.amazon.com/codewhisperer/resources/#Getting_started/), Authenticate and you're ready to start leveraging its features.

## Experimenting with Amazon Q and Amazon CodeWhisperer

I built a full-stack application using React, NextJs, and AWS Serverless. Check out the [blog post](https://dev.to/aws-builders/story-telling-app-with-amazon-bedrock-1259) for a guide on incorporating ML features with Amazon Bedrock into your application. In this part, I'll explain how I used Amazon Q and CodeWhisperer to rebuild the story generator lambda function in my app. Since I wasn't familiar with the SST framework and Svelte initially, I did some reading and [watched tutorials](https://www.youtube.com/watch?v=E547i_xPqrU) before using Amazon Q to assess responses or CodeWhisperer's code recommendations.

## Amazon Q For Analysing And Explanation
I began by asking Amazon Q about the SST framework, hoping for a quick and helpful response.


![what-is-sst-answer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kxab29qvywkmf73pi1z2.png)

Next, I am keen to know how SST integrates with Svelte.


![how-to-integrate-sst-with-svelte](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vldozin0ctp83a15zpql.png)

This convinces me. Now, let's find out how to get started with Svelte. I asked Amazon Q for guidance.


![create-svelte-app](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9nf54ix7h9ao9moctogq.png)

I ran the suggested command, and the Svelte app was created successfully. Then, I asked Amazon Q to explain the structure of a Svelte project.


![cli-command](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qk0ec496sgq2yjm0n4sw.png)


![svelte-app](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yba6zfcriwg8vambeo4s.png)


![svelte-explanations](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tyossgm06cnn6u7qae74.png)

Before diving into this experiment, I studied the concept of using SST as a Serverless stack with a UI framework like Svelte. The key idea is to have a mono repo, a recommended structure that makes all resources accessible to the Frontend.

Understanding these fundamental concepts, even with an AI assistant, helps in asking accurate questions and receiving precise answers. This approach prevents blindly accepting the assistant's recommendations.

Next, I'll use Amazon Q to inquire about creating an SST Stack and initialising a Svelte app within an SST app.


![create-sst-app](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c6cby2f0vzgea57b2alc.png)

I like how Amazon Q gives a source link for each part of the answer and suggests follow-up questions as you can see in the screenshots. In this case, I found the SST app creation command in the source. After a few minutes, the SST app was successfully created. To follow best practices, I'll move the Svelte app to the my-sst-app/packages folder, turning the project into a mono repository. Alternatively, you can create a new Svelte app within the SST App.

## Amazon Q & CodeWhisperer For Coding
Now, with our SST and Svelte apps set up, let's try out Amazon CodeWhisperer and request an explanation of the code from Amazon Q. We'll use Amazon CodeWhisperer to write the initial lambda function to generate a story with Amazon Bedrock.

Here's the pseudo-code for the lambda function:

![pseudo-coded-lambda](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iulu35qbggnvlm0k327w.png)

When using Amazon CodeWhisperer, wait for suggestions based on your pseudo code, then choose the most relevant one. Alternatively, start typing, and it will provide recommendations. Proceed line by line to complete the lambda function, and I will analyse the suggestions once the lambda implementation is finished.

- To bring in the bedrock client in my SST App, I referred to Amazon Q for guidance.


![how-import-bedrock-client](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k235ulkfzz38m77267um.png)

- Extract and validate the topic from the lambda event

![extract-topic](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqu91f9ciwz7tuk3jf8x.png)


![validate-topic](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ra7u3w8v2v5puoqkl7zb.png)

- Construct Prompt

![propmpt](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/td7mg6zg0lws0y8n0k0j.png)

- Construct Payload

![construct payload](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/21sf1il0gsnyptstkuic.png)

- Initialise Bedrock Client and invoke the model

![bedrock-client](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ii48o0rsyzb8iyhi3ken.png)

![invoke command](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/88np1198cix044obanks.png)

## Amazon Q For Debugging

Close to completing the lambda implementation. After applying the suggested code for model invocation, I had to import InvokeModelCommand from Amazon Bedrock. Let's ask Amazon Q about importing the module.


![invoke model](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wvsfy65duqj9ssfb6gwd.png)

If I follow the suggestions, I'll encounter an import resolution error. Now, I'm using Amazon Q for debugging.

![error](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/za6vrqbkhxy70b7y0i97.png)


![amazon q debugging](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/leb6mu98zyoxh38067p7.png)

I've used the Amazon Bedrock SDK before, and I know that `InvokeModelCommand` is in the [client-bedrock-runtime ](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/bedrock-runtime/)package. Despite tweaking my question for specificity, the response continued to reference the `client-bedrock` package. Just to be thorough, I asked the same question to ChatGPT and received a similar response.

![chatgpt debugging](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bh5eexacqg11arodrjpw.png)

The answer seems a bit misleading. As I followed the AI assistant's suggestions for implementing the lambda function, more errors occurred. For example, I had to import the Bedrock Client from `client-bedrock-runtime`, and the suggested payload was incorrect. The AI couldn't guide me on how to destructure the generated text response from the Text Model. After fixing these issues, the lambda function for generating the story is now implemented properly.


![implemented lambda](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wuziiwudvj4usaq4g9i4.png)

So far, I used Amazon Q and CodeWhisperer for various tasks like general knowledge questions, coding, and debugging. This experiment continued, I explored using Amazon Q to integrate an AppSync API resource into an SST Stack, deploying the stack, and creating a simple form with a single input field in Svelte. To keep this post concise, I'll conclude my documentation of this experiment here. In the next part, I'll share my thoughts on how the experiment went.

## How Did This Experiment Go?
My experiment with Amazon Q and CodeWhisperer wasn't limited to a lambda function; I used CodeWhisperer in Amazon Glue Studio and found it efficient.

Will I use or recommend Amazon Q? Absolutely. Setting it up in my VSCode is convenient, and it's not just for coding – Amazon Q works magic for data analytics and architecture solutions. Check out [Wendy's blog post](https://dev.to/aws-heroes/amazon-q-in-amazon-quicksight-previewpart-1-build-dashboards-with-nlp-339o), an AWS Data Hero, explaining how Amazon Q integrates with Amazon Insights and unleashes its power. The provided source link is also helpful.

Are AI answers convincing? I'd say they're quite good. They work well not just for coding and debugging; if you provide an Infrastructure as Code (IaC) template, the AI can analyze it and suggest AWS best practices. When using AI assistants like ChatGPT or Amazon Q, the key is the user's input or "Prompt."

The assistant answers and recommends based on your input. For instance, when a lambda implementation error occurred, I used Amazon CodeWhisperer to import the Bedrock Client package. This time, modified the pseudo code from `import Bedrock Client` to `import Bedrock runtime client`, and it correctly imported the modules. Pseudo-code precision matters and CodeWhisperer also recommends based on existing code.


![bedrock-runtime-client](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tr2qbgguwauzn51exi4w.png)

Will I use AI assistants for learning and software development?

It depends on whether they're designed for training and learning purposes. Otherwise, following their suggestions might be confusing. They're meant to assist, not do the job for you. I tested Amazon Q and Amazon CodeWhisperer for error fixing and code optimisation, and they performed well. While expecting AI bots like ChatGPT, Amazon Q, or Microsoft Copilot to build your app may be premature, Amazon Q provides solid AWS best practices recommendations.


![analyse IaC](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hs5zblezssumxhwheoj9.png)


![best practices](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0jkmz4w521y8t6814s1c.png)

Should we worry about AI taking over our jobs?
I believe that AI/ML is here to assist and improve our lives. AI extends beyond the technology, impacting various domains with daily use cases. However, will it replace our roles soon? I remain optimistic and say no. We build and train AI solutions, teaching them to save time, cost, and lives. the intention is not to replace roles but practicing responsible use of AI can lead to a brighter future.

In closing, I want to share one of my favourite paragraphs from Chip Huyen's book "Designing Machine Learning Systems." All credit to the author.

> In early 2020, the Turning Award winner Professor Geoffrey Hinton proposed a heatedly debated question about the importance of interpretability in ML systems. Suppose you have cancer and you have to choose between a black box AI surgeon who can not explain how it works but has a 90% cure rate and a human surgeon with an 80% cure rate. Do you want the AI surgeon to be illegal? A couple of weeks later, when I asked this question to a group of 30 technology executives at public nontech companies, only half of them would want the highly effective but unable-to-explain AI surgeon to operate on them. The other half wanted the human surgeon. While most of us are comfortable with using a microwave without understanding how it works, many don't feel the same way about AI yet, especially if that AI makes important decisions about their lives.