In the keynote demo Chris Wolf showed how SafeCoder could be used to safely complete some python code using a machine learning model which had been trained on the internal VMware code base, it gave great results and showed how using code completion can be safely used by providing an on-premises solution, SafeCoder made sure your company’s core IP or code was not sent to a public service and shared with the world whilst giving you the benefit of code assisted development.
I was intrigued by the demo and wondered how easy it would be and what kind of job the Hugging Face Code Autocomplete plugin for Visual Studio Code would do with PowerShell and specifically PowerCLI Code. Imagine having a LucD sat over your shoulder as you type, suggesting what your code should look like… well its not quite as amazing as Luc, I mean we all strive for that!
I was however impressed, below you can see a quick gif of me using it to create some comments about what I want to do it and it filling out the code as I do so, this is an awesome head start to creating your own scripts and learning.
Note: The current implementation uses the Hugging Face API and model which was trained on the internet so the data wont be 100% accurate, it will do a great job of giving you the fundamentals but rounding the edges and ensuring the script does what you need it to do will be your responsibility!
Installing Hugging Face Code Autocomplete in VSCode
- Install VS Code if you don’t have it already.
- Install the VS Code plugin from here.
- Sign up for a Hugging Face account (free), you will need this for the plugin to access their API.
- Setup an API token which you can use for VS Code to access the Hugging Face API.
- In VS Code press Cmd/Ctrl+Shift+P to open VSCode command palette.
- Type: Hugging Face Code: Set API token.
- Paste your API token into the plugin.
- You are done! I normally type #PowerShell Code as my first comment to help it know that’s what i expect and not some other language.