
CodeWhisperer - Code Suggestions
How does CodeWhisperer Generate Code Suggestions?
Amazon CodeWhisperer uses machine learning models to understand the code you are currently writing. It analyzes the code you have written till now and based on that information it generates code suggestions in real time.
- As soon as you start typing code in your editor, CodeWhisperer processes the context of your current code.
- After processing, CodeWhisperer provides suggestions that help you complete functions, methods, and even entire blocks of code.
- CodeWhisperer has been designed to predict what you might need next, whether it is a variable, function name, or common code structure. These suggestions are especially useful for repetitive tasks.
The ML model used by CodeWhisperer is trained on large language models (LLMs) which mainly includes common coding patterns, functions, and libraries across various programming languages.
Examples of Code Suggestions
Amazon CodeWhisperer supports multiple programming languages, including Python, Java, and JavaScript.
Lets see how CodeWhisperer provides suggestion for Python language in Jupyter Notebook −

In JavaScript, for example, if you are trying to create an event listener for a button click, CodeWhisperer might suggest the following −
document.getElementById('myButton').addEventListener('click', function() { alert('Button clicked!'); });
It helps you complete the code for adding event listeners or other DOM manipulations efficiently.
Customizing CodeWhisperer Suggestions
One of the key features of Amazon CodeWhisperer is that it allows you to customize the suggestions to match your coding style and preferences.
Adjusting Suggestion Frequency
You can adjust how frequently you want coding suggestions. Suppose if you think you are getting too many suggestions, you can decrease the frequency in the settings menu. On the other hand, if you want more detailed suggestions, you can increase the complexity of the suggested code blocks.
Customizing Code Blocks
Amazon CodeWhisperer does not only provide single-line suggestions, but you can also choose to receive suggestions for entire blocks of code.
If you are working on a big project where you frequently repeat similar code patterns, you can customize CodeWhisperer to suggest entire code snippets. It saves the time of developer on writing code.
Pause Automatic Code Suggestions
You can also pause automatic code suggestions in Amazon CodeWhisperer. Given below is an example that shows how to pause and resume automatic code suggestions by CodeWhisperer in Jupyterlab −

Language-Specific Customization
You can also customize CodeWhisperer depending on the programming language you are using. For example, you can customize it for more detailed suggestions in Python but limit them in JavaScript to single-line code suggestions.
Ignoring Specific Suggestions
If there are some specific types of suggestions that you do not find useful, you can customize CodeWhisperer to ignore them.
For example, if you are comfortable in writing your variable names, you can customize CodeWhisperer to only provide suggestions for more complex parts of your code.