Code Clippy — Inline code suggestions from your friendly neighborhood hacker Clippy for VSCode
Courtesy of the awesome Aimee Trevett!
This extension is an effort to create an open source version of Github Copilot where both the extension, model, and data that the model was trained on is free for everyone to use. If you'd like to learn more about how the model power Code Clippy, check out this repo.
This extension also sits completely atop this other clone of Github Copilot aptly named Captain Stack, since instead of synthesizing the answers using deep learning, it extracts them from StackOverflow posts.
Demo
Table of contents:
1. How to Install
In order to use the extension, you will need to download and install VSCode Insider and Node and npm (tested on Node 10.19.0
and npm 7.13.0
). Additionally, you will need a Huggingface account in order to obtain the necessary API key that is used to authorize calls to Huggingface's Inference API.
Download and install Code Clippy:
git clone https://github.com/CodedotAl/code-clippy-vscode
cd code-clippy-vscode
npm install
code-insiders .
2. Using Code Clippy
Once VSCode Insider has opened up, you can press F5 to launch the extension in another VSCode window in debug model that you can test out. Open up a file of your choice in the new VSCode window and start typing. You will be prompted to enter an API key, go to your Huggingface account's API token page and copy your API key and paste it into the prompt. Now you should be able to type and see suggestions! To accept a suggestion, just press tab and to cycle through different suggestions press ALT + [
to go to the next suggestion or ALT + ]
to go to the previous one.
Note -
It can take a few seconds (~20seconds) to spin up the model on Huggingface's servers, so if you get an error about waiting for the model to load, just give it about 20 seconds and try again. If you don't see any suggestions, make sure that showInlineCompletions
is enabled in your settings:
"editor.inlineSuggest.enabled": true
Additionally, Huggingface's Inference API free tier has a limited amount of requests you can make per hour and per month so if you are on the free tier you will only be able to use the extension as a demo. If you would like to be able to use the extension without this limitation you can host the model yourself and edit the code to send requests there or you can upgrade your Huggingface account to a different tier.
You can also edit the model used to generate the code suggestions. I recommend using EleutherAI/gpt-neo-1.3B or EleutherAI/gpt-neo-2.7B over the default as in my testing they produce a lot better suggestions, but is significantly slower. To edit the model press CTRL + SHIFT + P
to bring up the command prompt and type settings and select "Preferences: Open User Settings". This will open another tap with your settings. Search for "code clippy" and update the "Hf Model Name" configuration to be whatever model you want such as:
EleutherAI/gpt-neo-1.3B
From these code clippy settings, you can also update your API key or enable using GPU for doing the generation. However, for this feature to work, you need to have at least the Startup tier for Huggingface's Inference API.