Amazon CodeWhisperer - Explore efficient programming paradigms

Preface

I went to check out the Amazon event I saw on CSDN. The whole experience process was very nice. I used VSCode for testing and chose python as the language. I felt a lot of speed in the process of testing the AI ​​code prompts. , once again leaving a mark, it can also be considered as providing everyone with a solution to improve efficient coding.

Event homepage: Amazon Cloud Technology Developer Community

Before the formal explanation, we need to have a certain understanding of AI programming:

What is AI programming

AI programming is a process of developing and building software applications using artificial intelligence (AI) technology. It involves using machine learning, deep learning, and other related techniques to train computer systems to automate specific tasks or simulate human intelligence.

What is the difference between artificial intelligence programming and traditional programming?

There are several differences between artificial intelligence programming and traditional programming:

  1. Data-driven: Artificial intelligence programming pays more attention to data processing and learning, using large amounts of data to train models so that they can automatically make inferences and decisions. Traditional programming pays more attention to the design of rules and logic.

  2. Autonomous learning: The goal of artificial intelligence programming is to enable computers to learn from data and improve their own performance, while traditional programming implements specific functions by manually writing code.

  3. Non-determinism: There is a certain degree of non-determinism in artificial intelligence programming, because the prediction results of the model may be affected by a variety of factors. Traditional programming obtains certain results through clear rules and logical reasoning.

  4. Adaptability: AI-programmed models can adapt and adjust to new data and environments, thereby improving performance. Traditional programming generally requires manual modification of code to adapt to new needs.

In what fields does artificial intelligence programming have applications?

Artificial intelligence programming has wide applications in many fields, including but not limited to the following aspects:

  1. Natural Language Processing (NLP): Artificial intelligence programming can be used to build intelligent voice assistants, machine translation, sentiment analysis, text generation and other tasks.

  2. Machine Learning (ML): Artificial Intelligence programming can be used for the development and training of machine learning algorithms, such as classification, regression, clustering, etc.

  3. Computer Vision (CV): Artificial intelligence programming can be used for image recognition, object detection, face recognition, image generation and other related tasks.

  4. Autonomous driving: Artificial intelligence programming is also used in autonomous driving technology for real-time environment perception, path planning, decision-making, etc.

  5. Financial field: Artificial intelligence programming can be used for tasks such as financial market prediction, risk assessment, and portfolio optimization.

  6. Healthcare: Artificial intelligence programming can be applied to medical image analysis, disease prediction, personalized treatment and other fields.

  7. Intelligent recommendation system: Artificial intelligence programming can be used to build personalized recommendation systems, such as movie recommendations, product recommendations, etc.

At this point, we have a certain understanding of AI programming, and we also know the difference between artificial intelligence programming and traditional programming. Then we understand some application fields of artificial intelligence programming.

Problems solved by Amazon CodeWhisperer

Amazon CodeWhisperer is an AI tool designed to help developers solve the problem of rapid code editing. It provides features such as smart prompts, code auto-completion, and error detection to support developers in their coding work.

CodeWhisperer can provide suggestions about code structure, functions and variables by analyzing the given code and contextual information. It helps developers find errors faster and provide possible solutions while writing code.

Additionally, CodeWhisperer identifies common coding patterns and best practices and provides recommendations accordingly. It helps developers improve code quality, increase efficiency, and reduce errors.

The above is the official statement, so as a programmer, the understanding of [Amazon CodeWhisperer] is to give us follow-up code tips through certain comments and the current code. It's quite confusing, let's test it next.

Amazon CodeWhisperer - VSCode plug-in installation

Directly search for [CodeWhisperer] in the vscode plug-in library to see [AWS Toolkit] and click [Insert] to install it. After installation, you can see the corresponding menu function directly on the left.

We enter the corresponding menu function:

I have activated it here. If it has not been activated, you can log in directly.

If you don’t have an account, just register directly. Register using email. You will be asked for a verification code during the process.

After completion, there will be a prompt like this:

After seeing this prompt, you can return to VSCode. At this time, you will see the following prompt:

OK let’s start our specific test.

Amazon CodeWhisperer tests Python language

Let’s simply test a few writing methods to see what operations are needed to get prompts.

empty def test

You can see that there is f(x), f is a rule, and x is a parameter. It can be regarded as giving a basic hint, because we have not given anything, and it has no way to analyze it.

Comes with def name test

def a test, here we just give a letter a as the name of the current function and see how it guesses.

There is only one letter that is difficult to associate, so we will come up with a few more.

def add test

This is the return of 2 values, so how many more values ​​do I want? have a test.

This function is written as def add_three_sum(a), and the following prompt is automatically given. Then I will write this number larger.

It won't work when it's changed to Ten.

The writing method of this function name is quite limited. You cannot use a long name to write the function name. It is too troublesome. So let’s refer to the official website for other operation methods.

Tip documentation: Amazon CodeWhisperer Workshop

The manual says that you can use comments to complete prompts, so let's try what kind of comments it is.

We all know that python generally uses a [#] for comments, and class and function comments use three double quotes. Let’s experiment.

Annotation test

The test comments are in Chinese.

We ran the code given

It can be seen that the result is correct, which is really good. So whether we can use some import content, let's continue testing.

Introducing requests package code testing

It really gave me a hint.

There is none without comments.

The effect after hitting Enter. 

It should be automatically prompted according to a certain format code.

If there are no new prompts, the following content will be executed in a loop:

Although the content is specific, the tips given are still very good.

There are also various automatic prompts, which is quite good.

Summarize

Although the test content is not much, what we test are the most basic specifications and usage methods. Under this operation, we can slowly become proficient in various prompts to help us quickly complete our code development. There is no test of the Java language. , I believe that the content of Java prompts will be more and more complete. After all, the number of Java users and the amount of code is still very large, and it is more convenient to train the model.

There are currently activities and there are a lot of gifts. After all, let me show you the approximate prizes for the activities CSDN participates in:

There are still many rewards, and I look forward to everyone’s participation and finding more and better ways to use it. I wish everyone a happy coding.

Guess you like

Origin blog.csdn.net/feng8403000/article/details/133157934