Bye Copilot - How to Create a Local AI Coding Assistant for Free
Tags: ai, githubcopilot, codingassistant, codeassistant
Published: 2024-06-26 23:22:03

---
title: Bye Copilot - How to Create a Local AI Coding Assistant for Free
published: true
date: 2024-06-24 00:00:00 UTC
tags: ai,copilot,codingassistant,codeassistant
canonical_url: https://www.davegray.codes/posts/bye-copilot-how-to-create-a-local-ai-coding-assistant-for-free
cover_image: https://raw.githubusercontent.com/gitdagray/my-blogposts/main/images/bye-copilot-how-to-create-a-local-ai-coding-assistant-for-free.png
---

**TLDR:** Create your own local AI Coding Assistant that integrates with VS Code.

## AI Coding Assistants

I didn't jump onboard the AI Coding Assistant train at first. 

However, I now open up a chat with [ChatGPT](https://chatgpt.com/) as often as I do MDN.

I've found it's often a quicker reference for exactly what I need. 

I have considered paying the monthly fee for [GitHub Copilot](https://github.com/features/copilot), but what if you could use open source large language models (LLMs) to create your own AI Coding Assistant? 

Now you can.

## Install Ollama

Start by going to [Ollama.com](https://ollama.com/) and downloading the version for your operating system. 

Note: As I write this, the Windows version is still considered a "preview". After installing on Windows, I had to restart my computer for `ollama` to be available at the command line.

Open a terminal window and type `ollama --help` to confirm you have Ollama installed and your computer can find it.

## Pick an Open Source LLM 

Visit the [EvalPlus Leaderboard](https://evalplus.github.io/leaderboard.html) where the performance of many models are compared. 

There are currently a couple of options in the EvalPlus Top 5 to consider: `DeepSeek-Coder-v2` and `CodeQwen1.5`. 

Before choosing, go back to [Ollama.com](https://ollama.com/) and search the models to look at their details. 

I personally decided to go with [codeqwen](https://ollama.com/library/codeqwen). It is a 4.2GB download and `deepseek-coder-v2` is 8.9GB.

You can try out several LLMs if you want to.

After choosing at least one, copy the `ollama` command and run it in your terminal window to download your LLM of choice. 

For example, the command on the [codeqwen](https://ollama.com/library/codeqwen) page is `ollama run codeqwen`.

## Add the Continue VS Code Extension 

Open up VS Code and click the extensions menu icon. 

Search for `continue`. 

You should find `Continue` by [continue.dev](https://www.continue.dev/).

Install the extension and you should find it by icon or name in the activity bar afterwards. 
 
Click it to open and you should see a splash screen. 

The screen will confirm Ollama is installed and provide other recommendations that you can ignore. 

Click the "Local" button and the "next / continue" button. 

You should now have a chat screen that opened over your filetree (if your filetree is on the left side).

## Configuring Continue

At the bottom of the chat window, select `Ollama - codeqwen:latest` from the menu. 

Click the settings icon to open up the `config.json` file. 

Look for the `tabAutocompleteModel` setting. 

Change both the `title` and `model` values to `codeqwen`.

You will also see a `custom commands` setting like this:

```json 
"customCommands": [
    {
      "name": "test",
      "prompt": "{{{ input }}}\n\nWrite a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.",
      "description": "Write unit tests for highlighted code"
    }
  ],
```
You can add your own custom commands here. In this example, if you highlight a function in your code and type `test` in the chat window, it will execute the prompt you see. 

Here's an example of a custom command I added: 

```json 
"customCommands": [
    {
      "name": "test",
      "prompt": "{{{ input }}}\n\nWrite a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.",
      "description": "Write unit tests for highlighted code"
    },
    {
      "name": "step",
      "prompt": "{{{ input }}}\n\nExplain the selected code step by step.",
      "description": "Code explanation"
    }
  ],
```

## Getting Started:

Click the help icon at the bottom right of the chat window. 

It provides a link to a tutorial, web resources and keyboard shortcuts. 

A couple of quick things to try: 

- Select some existing code in your file, then press `Ctrl+L`  to start a chat on the selected code. 

- Select some existing code in your file, then type `test` in the chat window, and press enter to generate unit tests for that code.

- Create a new empty code file, press `Ctrl+i` and type instructions for code generation. Then watch your AI Code Assistant generate the code. 

- Start typing code in a file and look for the autocompletion suggestions. Press tab to use them.

<hr />

## Let's Connect!

Hi, I'm Dave. I work as a full-time developer, instructor and creator. 

If you enjoyed this article, you might enjoy my other content, too.

**My Stuff:** [Courses, Cheat Sheets, Roadmaps](https://courses.davegray.codes/)

**My Blog:** [davegray.codes](https://www.davegray.codes/)

**YouTube:**  [@davegrayteachescode](https://www.youtube.com/davegrayteachescode) 

**X:**  [@yesdavidgray](https://x.com/yesdavidgray)  

**GitHub:** [gitdagray](https://github.com/gitdagray)

**LinkedIn:**  [/in/davidagray](https://www.linkedin.com/in/davidagray/) 

**Patreon:**  [Join my Support Team!](patreon.com/davegray)

**Buy Me A Coffee:**  [You will have my sincere gratitude](https://www.buymeacoffee.com/davegray)   

Thank you for joining me on this journey. 

Dave