title: Free AI code generation tool
date: 2023-08-13
categories:
- AI
tags: - AI
Free AI Code Generation Tool
Introduction to CodeWhisperer
CodeWhisperer is a general-purpose machine learning-based code generator produced by Amazon that provides code suggestions in real time.
As we code, it automatically generates suggestions based on our existing code and comments. It gives us personalized advice of all sizes and scopes, from one-line code suggestions to complete functions.
CodeWhisperer can also scan our code to highlight and define security issues.
mainly because he is free
Official website address
Free Edition Permissions
free for personal use
Unlimited code suggestions
reference tracking
50 security scans (per user per month)
Install
Kind tips
The installation process needs to open the magic tool. The lower version of idea and vscode do not support this tool. You need an email account, register CodeWhisperer and receive the verification code
IntelliJ IDEA installation
The lower version can't be used. My version is 2023.2 (2021.1 is not easy to use)
Open the configuration window in IDEA, select the plug-in , search AWS Toolkit
, click Install , and click the OK button, as shown below:
Note that restart IDEA after installation, and it will be ok when aws appears.
Log in to your AWS account
Select "Use a personal email to sign up and sign in with AWS Builder ID" in the pop-up window, and click the "Connect" button, as shown in the figure below:
Click Open and Copy Code
After arriving at this page, we will directly paste it with Ctrl+V, and the code generated above will be automatically pasted here
Then enter your email, I use 163 email
Click the "Allow" button on the last page (you can see the steps of vscode installation, because my idea version 2022 does not support this plug-in, so the first operation vscode, idea and vscode create the same steps for the AWS builder ID)
After success, the idea is displayed as follows
The code generation function can be turned on or off in the Developer Tools in the AWS Toolkit view, as shown in the figure below:
For testing, I will take [the interface of querying users according to the id of the user collection] as an example
Write out the requirements first, then use shortcut keys to generate code
How to use shortcut keys
You need to press the shortcut key to call Codewhisperer throughout the process. The main usages are as follows:
shortcut key function
ALT + C | Ask for suggestions (press tab to accept suggestions when a dark word appears) |
---|---|
TAB | accept suggestion |
ESC | cancel suggestion |
→ | select next suggestion |
← | select previous suggestion |
The final generated code is as follows
//根据用户集合的id查询用户集合
/***********************************
* 用途讀述:
* @param ids
* 返回値讀述:
* @return List<User>
***********************************/
@PostMapping("/list")
public List<User> findList(@RequestBody List<Integer> ids){
return userService.listByIds(ids);
}
vscode installation
Search in the extension store AWS Toolkit
to install
[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-JPOaa1k7-1692363616508)(/assets/ai/money/1-1/1.png)]
After the installation is complete, the word aws will appear on the left
[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-kY1V1tp1-1692363616508)(/assets/ai/money/1-1/2.png)]
Then click account login
[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-NbZ9rI2j-1692363616509)(/assets/ai/money/1-1/3.png)]
The following pop-up box appears, click
[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-irsDjbFz-1692363616509)(/assets/ai/money/1-1/4.png)]
click to open
[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-hibnbtYJ-1692363616510)(/assets/ai/money/1-1/5.png)]
After arriving at this page, we will paste it directly with Ctrl+V
[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-pOODms60-1692363616510)(/assets/ai/money/1-1/6.png)]
Then enter your email
[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-pyo4UCF3-1692363616511)(/assets/ai/money/1-1/7.png)]
Followed by the normal email verification and account registration link
[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-MfX1klPa-1692363616511)(/assets/ai/money/1-1/8.png)]
Enter email verification code
[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-Ox5duyoJ-1692363616511)(/assets/ai/money/1-1/9.png)]
enter password
[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-dMAQsqXf-1692363616512)(/assets/ai/money/1-1/10.png)]
click allow
[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-1X4Hu1oj-1692363616512)(/assets/ai/money/1-1/11.png)]
Finish
[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-JpWvQBz2-1692363616513)(/assets/ai/money/1-1/12.png)]
After success in vs
[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-pDGKVJJY-1692363616513)(/assets/ai/money/1-1/13.png)]
test
Annotate generated code
[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-meyBduRf-1692363616514)(/assets/ai/money/1-1/14.png)]
Press tab to accept code
[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-X91IgUqa-1692363616514)(/assets/ai/money/1-1/15.png)]
[External link image transfer...(img-pDGKVJJY-1692363616513)]
test
Annotate generated code
[External link image transfer...(img-meyBduRf-1692363616514)]
Press tab to accept code
[External link image transfer...(img-X91IgUqa-1692363616514)]