Git Product home page Git Product logo

code-clippy-vscode's Introduction

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
  2. Using Code Clippy
  3. Limitations

1. How to Install

In order to use the extension, you will need to download and install VSCode 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 .

1b. How to Install as a Packaged Extension

Alternatively to running the extension in debug mode, you can package it locally and install it.

$ npm run esbuild
$ vsce package

Say 'y' to the warning. Then install the extension with vscode➡️…➡️Install from VSIX➡️<install directory/code-clippy-0.0.1.vsix>. Finally, once installed, set conf.resource.hfAPIKey to your HuggingFace API key.

Note - You may need to update your Node version to build the package. If you get an error like this:

    return (translations ?? [])
                          ^

SyntaxError: Unexpected token ?

Tested on Node v16.17.0 and npm v7.13.0.


2. Using Code Clippy

Once VSCode 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.


3. Limitations

Important - First and formost, this extension is a prototype and the model it was trained on is for research purposes only and should not be used for developing real world applications. This is because the default model that is used to generate the code suggestions was trained on a large set of data scraped from GitHub that might have contained things such as vulnerable code or private information such as private keys or passwords. Vulnerable code or private information can and therefore probably will leak into the suggestions. Currently the suggestions are just limited to a few additional tokens since the model starts to hallucinate variables and methods the longer suggestions it is allowed to generate. If you would like to read more about the shortcomings of the model used in the generation and data used to train the model please refer to this model card and datasheet that explain it more in-depth. If you would like to learn more about how the model was trained and data was collected please refer to this repository.

code-clippy-vscode's People

Contributors

aramix avatar dineshknokia avatar dineshreddyk avatar hieunc229 avatar kek5chen avatar kingstut avatar ncoop57 avatar reshinthadithyan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

code-clippy-vscode's Issues

Plans for more plugins?

This probably isn't the best place for this, but I didn't see any other place that was more appropriate.

Any plans of releasing more plugins for other editors such as neovim?

CustomLinecompletionItem is not assignable

Hello, I tried to install the code-clippy-vscode, but I encounter this error:

Argument of type '{ text: string; range: vscode.Range; trackingId: string; }' is not assignable to parameter of type 'CustomInlineCompletionItem'.

Is there something I just missed?

Cannot start the program with F5

Hi,
I just installed vscode insiders for windows and cloned the repo. When opening it as hitting F5 here's what I am getting

src/extension.ts:67:7 - error TS2345: Argument of type '{ text: string; range: vscode.Range; trackingId: string; }' is not assignable to parameter of type 'CustomInlineCompletionItem'.
  Object literal may only specify known properties, and 'text' does not exist in type 'CustomInlineCompletionItem'.

67       text: rs.completions[i],
         ~~~~~~~~~~~~~~~~~~~~~~~

[10:25:11] Found 1 error. Watching for file changes.

Not knowing nodejs, i have no clue where to start

[Duplicate] Argument not assignable to parameter of type 'CustomInlineCompletionItem'.

STR:

  1. type code . to open VSCode
  2. press F5.

Symptom:
An error dialog shows Error exists after running preLaunchTask 'npm: watch'.

Detailed error:

[{
	"resource": "/c:/Users/User/Documents/code-clippy-vscode/src/extension.ts",
	"owner": "typescript",
	"code": "2345",
	"severity": 8,
	"message": "Argument of type '{ text: string; range: vscode.Range; trackingId: string; }' is not assignable to parameter of type 'CustomInlineCompletionItem'.",
	"source": "ts",
	"startLineNumber": 67,
	"startColumn": 7,
	"endLineNumber": 67,
	"endColumn": 7
}]

API error, extension won't start

I'm trying to enable the extension by compiling it as reported in the readme, the code compiles with the command npm run esbuild and the extension gets generated correctly with vsce package.

I make sure to have the correct api key in the configuration, but the extension throws this error at startup:

editor/inlineCompletions/actions is a proposed menu identifier. It requires 'package.json#enabledApiProposals: ["inlineCompletionsAdditions"]' and is only available when running out of dev or with the following command line switch: --enable-proposed-api ncoop57.code-clippy

Looks like that inlineCompletionsAdditions is the API to be used instead of inlineCompletions in package.json, but even with that and after adding --enable-proposed-api ncoop57.code-clippy in .vscode/launch.json, the error still persists.

Any idea why? Running VSCode 1.71.0, (not insider as it's not required anymore), node 17.6.0, npm 8.5.1

Install error - vscode-dts/vscode.proposed.inlineCompletions.d.ts not found

npm install

...
From: https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.inlineCompletions.d.ts
Read more about proposed API at: https://code.visualstudio.com/api/advanced-topics/using-proposed-api
Failed to get https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.inlineCompletions.d.ts
...

Missing script "esbuild"

From within VSC:

tizu69@pop-os:/media/tizu69/CodingProjects/code-clippy-vscode$ npm run esbuild
npm ERR! Missing script: "esbuild"
npm ERR! 
npm ERR! Did you mean this?
npm ERR!     npm rebuild # Rebuild a package
npm ERR! 
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/tizu69/.npm/_logs/2022-12-04T17_42_14_492Z-debug-0.log
tizu69@pop-os:/media/tizu69/CodingProjects/code-clippy-vscode$ 

Getting errors trying to put HuggingFace API

Hi! I'm sorry, but i can't put the HuggingFace API; I get this:
image

I'm sure that i'm putting the api without spaces, or modifying it. I got this api doing "New Token", putting a random name (Clippy Code) and copying the generated text.

image

npm run vscode:prepublish Found 1 error in src/extension.ts:67 Argument of type '{ text: string; range: vscode.Range; trackingId: string; }' is not assignable to parameter of type 'CustomInlineCompletionItem'.

src/extension.ts:67:7 - error TS2345: Argument of type '{ text: string; range: vscode.Range; trackingId: string; }' is not assignable to parameter of type 'CustomInlineCompletionItem'.
Object literal may only specify known properties, and 'text' does not exist in type 'CustomInlineCompletionItem'.

67 text: rs.completions[i],
~~~~~~~~~~~~~~~~~~~~~~~

Found 1 error in src/extension.ts:67

Error: Authorization header is correct, but the token seems invalid

I have followed the steps of the instructions and I'm getting the error
Error: Authorization header is correct, but the token seems invalid
and
[ncoop57.code-clippy]: editor/inlineCompletions/actions is a proposed menu identifier. It requires 'package.json#enabledApiProposals: ["inlineCompletionsAdditions"]' and is only available when running out of dev or with the following command line switch: --enable-proposed-api ncoop57.code-clippy

I generated a new access token from huggingface and pasted it in an empty text document, but it doesn't seem to work.

First Run Error..

flax-community/gpt-neo-125M-code-clippy-dedup-2048
extensionHostProcess.js:113
{error: 'Authorization header is correct, but the token seems invalid'}

Coming on my end and it is not asking for API Key

downloading "vscode.proposed.inlineCompletions.d.ts" and "vscode.d.ts"

My network is not very good. When npm install, I will get stuck when downloading these two ts files. Can I skip this process of downloading ".ts"? Because I saw that these two files are already in the folder, I don't understand why npm still trying to download these two files.

error doing "code-insiders ." command "command not found"

Hello, I was trying to install this vscode extension but I have this error, anyone can help me ?
I didn't understood how to add the extension to vscode - insiders to make it work
When I open the repository on vscode - insiders and click on "run extension" I get this error: Capture d’écran 2022-06-22 à 11 11 32
And when I'm writing my api key in package.json and running extension I get this error:
Activating extension 'ncoop57.code-clippy' failed: vscode.window.getInlineCompletionItemController is not a function.
And this when i'm writing in a document when the extension run:
Error: Model flax-community/gpt-neo-125M-code-clippy-dedup-2048 is currently loading

Just tried installing code-clippy and getting error

Hello, I just tried to install code-clippy as I was interested in trying out the code completion. I cloned your extension and ran npm install on it. However when I ran the extension using f5 in vscode, according to your instructions, I encountered the following error.

I tried doing this on windows and in wsl running debian. I got the same error both times.

image

QUESTION: is it possible to use BLOOM model?

is it possible to use BLOOM model to finetune for specifically code generation?
maybe data should look like that
prompt:
sumTwoNumbers
target:
function sumTwoNumbers(a,b){
return a+b
}

so prompts to be function names and targets be whole function? so when we start typing function name it can generate function body?
I don't have enough experience in AI it's just an idea, because I have tested bloom model and is almost perfect for this task out of the box.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.