• Stars
    star
    797
  • Rank 55,037 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created 9 months ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The most no-nonsense locally hosted (or API hosted) AI code completion plugin for Visual Studio Code, like GitHub Copilot but 100% free and 100% private.

twinny

Are you fed up of all of those so called "free" Copilot alternatives with paywalls and signups? Fear not my developer friend!

Twinny is the most no-nonsense locally hosted (or api hosted) AI code completion plugin for Visual Studio Code and any compatible editors (like VSCodium) designed to work seamlessly with:

Like Github Copilot but 100% free and private.

Install twinny on the
Visual Studio Code extension marketplace

Main features

Fill in the middle code completion

Get AI based suggestions in real time. While coding you can let twinny autocomplete the code as you are typing.

Chat with AI about your code

Through the side bar, have a conversation with your model and get explanations about a function, ask it to write tests, ask for a refactor and much more.

Other features

  • Single or multiline fill-in-middle completions
  • Customisable prompt templates to add context to completions
  • Easy installation via vscode extensions marketplace or by downloading and running a binary directly
  • Customisable settings to change API provider, model name, port number and path
  • Ollama, llamacpp, oobabooga and LM Studio API compatible
  • Accept code solutions directly to editor
  • Create new documents from code blocks
  • Copy generated code solution blocks
  • Chat history preserved per workspace

🚀 Getting Started

With Ollama

  1. Install the VS code extension link (or if VSCodium)
  2. Install ollama
  3. Choose your model from the library (eg: codellama:7b)
ollama run codellama:7b
  1. Open VS code (if already open a restart might be needed) and press ctr + shift + T to open the side panel.

You should see the 🤖 icon indicating that twinny is ready to use.

  1. See Keyboard shortcuts to start using while coding 🎉

With llama.cpp / LM Studio / Oobabooga

  1. Install the VS code extension link (or if VSCodium)

  2. Get llama.cpp / LM Studio / Oobabooga

  3. Download and run the model locally using the chosen provider

  4. Open VS code (if already open a restart might be needed) and press ctr + shift + T to open the side panel.

  5. From the top ⚙️ icon open the settings page and in the Api Provider panel change from ollama to llamacpp (or others respectively).

  6. In the left panel you should see the 🤖 icon indicating that twinny is ready to use.

  7. See Keyboard shortcuts to start using while coding 🎉

With other providers

Twinny supports the OpenAI API specification so in theory any provider should work as long as it supports the specification.

If you find that isn't the case please open an issue with details of how you are having problems.

Note!

When choosing an API provider the port and API path names will be updated automatically based on the provider you choose to use. These options can also be set manually.

The option for chat model name and fim model name are only applicable to Ollama and Oobabooga providers.

Model support

Twinny works with any model as long as it can run on your machine and it exposes a OpenAI API compliant endpoint.

Choosing a model is influenced a lot by the machine it will be running, a smaller model will give you a faster response but with a loss in accuracy.

There are two functionalities that twinny are expecting from a model:

Models for Chat

Among LLM models, there are models called "instruct models", which are designed for a question & answer mode of chat.

All instruct models should work for chat generations, but the templates might need editing if using something other than codellama (they need to be updated with the special tokens).

  • For computers with a good GPU, use: deepseek-coder:6.7b-base-q5_K_M (or any other good instruct model).

Models for FIM (fill in the middle) completions

For FIM completions, you need to use LLM models called "base models". Unlike instruct models, base models will only try to complete your prompt. They are not designed to answer questions.

If using Llama the model must support the Llama special tokens.

  • For computers with a good GPU, use: deepseek-coder:base or codellama-code (or any other good model that is optimised for code completions).
  • For slower computers or computers using only CPU, use stable-code:3b-code-q4_0 (or any other small base model).

Keyboard shortcuts

Shortcut Description
ALT+\ Trigger inline code completion
CTRL+SHIFT+/ Stop the inline code generation
Tab Accept the inline code generated
CTRL+SHIFT+t Open twinny sidebar

Workspace context

In the settings there is an option called useFileContext this will keep track of sessions, keystrokes, visits and recency of visited files in the current workspace. This can be enabled to help improve the quality of completions, it's turned off by default.

Known issues

  • If the server settings are incorrectly set chat and fim completion will not work, if this is the case please open an issue with your error message.
  • Sometimes a restart of vscode is required for new settings to take effect, please open an issue if you are having problems with this.
  • Using file context often causes unreliable completions for FIM because small models get confused when provided with more than one file context.
  • See open issues on github to see any known issues that are not yet fixed.

If you have a problem with Twinny or have any suggestions please report them on github issues. Please include your vscode version and OS details in your issue.

Contributing

We are actively looking for contributors who want to help improve the project, if you are interested in helping out please reach out on twitter.

Contributions are welcome please open an issue describing your changes and open a pull request when ready.

This project is under MIT licence, please read the LICENSE file for more information.

Disclaimer

This plugin is provided "as is" and is under active development. This means that at times it may not work fully as expected.

More Repositories

1

express-typescript-starter

An Express.js project implemented using Typescript with strongly typed objects.
TypeScript
193
star
2

twinny-api

Locally hosted AI code completion server. Like Github Copilot but 100% free and 100% private.
Python
98
star
3

react-redux-typescript-bitcoin

A React, Redux and Typescript application for gathering live Bitcoin prices in a variety of currencies
TypeScript
17
star
4

gpt-code-reviewer

Use ChatGPT to conduct code reviews on your pull requests.
Python
16
star
5

express-typescript

Typescript and Express.js
TypeScript
11
star
6

ethereum-solidity-typescript-express-todo

A small application messing with Ethereum smart contracts
TypeScript
5
star
7

quintus

Document search and inference with GPT, Huggingface and Sentence Transformers.
Python
5
star
8

blockchain-node

Blockchain.info Bitcoin Wrapper For Node.js
JavaScript
4
star
9

coinbase-php

PHP Implementation of Coinbase API
PHP
3
star
10

harp.js-sass-grunt-starter

A Harp.js boilerplate using Grunt and Bourbon SASS
CSS
3
star
11

universal-typescript-redux-react-starter

A universal React, Redux and Typescript seed application.
TypeScript
2
star
12

string-tokeniser

An implementation of Keras Tokenizer in JavaScript.
JavaScript
2
star
13

pseudo

A console application that helps you run SudoLang programs.
Python
2
star
14

solidity-typescript-starter

Solidty and Typescript starter with auto generated abi interfaces and contract testing with mocha.
TypeScript
2
star
15

express-starter-es6-rethinkdb

A starter app for a simple express api with es6 and rethinkDB
JavaScript
1
star
16

express-typescript-starter-jwt

express-typescript-starter-jwt
TypeScript
1
star
17

bitpos-node

Node.js Wrapper for Bitpos
JavaScript
1
star
18

universal-es6-redux-react-starter

A universal React, Redux and ES6 starter application.
JavaScript
1
star
19

solidity-tenancy-agreement

solidity-tenancy-agreement
TypeScript
1
star
20

rjmacarthy-www

My website and blog
JavaScript
1
star
21

algernon

Algernon is a library for generating Typescript interfaces from solc compiled solidity abi definitions.
JavaScript
1
star
22

wiffy

A bip38 bitcoin paper wallet utility
JavaScript
1
star
23

cognitive-ts

Data structure utilities
TypeScript
1
star
24

for-dummies-elasticsearch-nest-examples

Nhibernate ElasticSearch For Dummies
C#
1
star
25

data-importer

A data importer for an API
JavaScript
1
star
26

llamallamallama

Llamallamallama is a chat solution that allows users to chat with "Llama" fine tuned with LoRa on the "Alpaca" dataset.
TypeScript
1
star
27

typescript-redux-react-seed

A React, Redux and Typescript seed application with React router.
JavaScript
1
star
28

express-github-webhook

GitHub webhook handler for push events
JavaScript
1
star