ruyimarone / huggingface-vscode

Code completion VSCode extension for OSS models

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Project for testing open source code completion models

It was forked from tabnine-vscode & modified for making it compatible with open sorurce code models on hf.co/models

Installing

Install just like any other vscode extension.

Be default, this extension is using bigcode/starcoder & Hugging Face Inference API for the inference. However, you can configure to make inference requests to your custom endpoint that is not Hugging Face Inference API. Thus, if you are using the default Hugging Face Inference AP inference, you'd need to provide HF API Token.

HF API token

You can supply your HF API token (hf.co/settings/token) with this command:

Testing

  1. Create a new python file
  2. Try typing def main():

Checking if the generated code in in The Stack

Hit Ctrl+Esc to check if the generated code is in in The Stack.

Developing

Make sure you've installed yarn on your system.

  1. Clone this repo: git clone https://github.com/huggingface/huggingface-vscode
  2. Install deps: cd huggingface-vscode && yarn install --frozen-lockfile
  3. In vscode, open Run and Debug side bar & click Launch Extension

Checking output

You can see input to & output from the code generation API:

  1. Open VSCode OUTPUT panel
  2. Choose Hugging Face Code

Configuring

You can configure: endpoint to where request will be sent and special tokens.

Example:

Let's say your current code is this:

import numpy as np
import scipy as sp
{YOUR_CURSOR_POSITION}
def hello_word():
    print("Hello world")

Then, the request body will look like:

const inputs = `{start token}import numpy as np\nimport scipy as sp\n{middle token}def hello_word():\n    print("Hello world"){end token}`
const data = {inputs, parameters:{max_new_tokens:256}};

const res = await fetch(endpoint, {
    body: JSON.stringify(data),
    headers,
    method: "POST"
});

About

Code completion VSCode extension for OSS models

License:MIT License


Languages

Language:TypeScript 95.9%Language:JavaScript 4.1%