Use Continue, Ollama, Codestral, and Koyeb GPUs to Build a Custom AI Code Assistant
Tags: webdev, programming, tutorial, ai
Published: 2024-06-28 13:12:00

[Continue](https://continue.dev) is an open-source AI code assistant that connects any models and context to build custom autocomplete prompts and chat experiences inside the IDE, like VS Code and JetBrains.

[Ollama](https://ollama.com/) is a self-hosted AI solution to run open-source large language models on your own infrastructure, and [Codestral](https://ollama.com/library/codestral) is [MistralAI's](https://mistral.ai/) first-ever code model designed for code generation tasks.

In this guide, we will demonstrate how to use Continue with [Ollama](https://www.koyeb.com/deploy/ollama), the [Mistral Codestral](https://mistral.ai/news/codestral/) model, and [Koyeb GPUs](https://www.koyeb.com/blog/gpus-public-preview-run-ai-workloads-on-h100-a100-l40s-and-more) to build a custom, self-hosted AI code assistant.

When complete, you will have a private AI code assistant for autocomplete prompts and chat available within VS Code and JetBrains.

## Requirements

To successfully follow and complete this guide, you need:

- A [Koyeb account](https://app.koyeb.com) to deploy and run Ollama
- [VS Code](https://code.visualstudio.com/) or [JetBrains](https://www.jetbrains.com/) installed on your machine

## Steps

To complete this guide and build a custom AI code assistant using Continue, Ollama, Codestral, and Koyeb GPUs, you need to follow these steps:

1. [**Deploy Ollama on Koyeb's GPUs**](#deploy-ollama-on-koyebs-gpus)
2. [**Install and configure the Continue package in VS Code**](#install-and-configure-the-continue-package-in-vs-code)
3. [**Get started with your custom AI code assistant**](#get-started-with-your-custom-ai-code-assistant)

## Deploy Ollama on Koyeb's GPUs

To get started, we will deploy Ollama on Koyeb's GPUs. Ollama will be used to run the Mistral Codestral model on a Koyeb RTX 4000 SFF ADA which is ideal for cost-effective AI inference and running open-source large language models.

To create and deploy Ollama on Koyeb, we will use the [Deploy to Koyeb](https://www.koyeb.com/docs/build-and-deploy/deploy-to-koyeb-button) button below:

[![Deploy to Koyeb](https://www.koyeb.com/static/images/deploy/button.svg)](https://app.koyeb.com/deploy?name=ollama&type=docker&image=ollama%2Follama&command=serve&instance_type=gpu-nvidia-rtx-4000-sff-ada&env%5B%5D=&ports=11434%3Bhttp%3B%2F)

On the service configuration page, you can customize the [Service](https://www.koyeb.com/docs/reference/services) name, [Instance](https://www.koyeb.com/docs/reference/instances) type, and other settings to match your requirements.

When you are ready, click the **Deploy** button to create the service and start the deployment process.

After a few seconds, your Ollama service will be deployed and running on Koyeb.

The next step is to pull the Mistral Codestral model to use it with Ollama. To do so, retrieve the Service URL from the Koyeb dashboard and run the following command in your terminal:

```bash
curl https://<YOUR_SUBDOMAIN>.koyeb.app/api/pull -d '{
  "name": "codestral"
}'
```

<Admonition>Take care to replace the base URL ending in `koyeb.app` with your actual service URL.</Admonition>

Ollama will pull the Mistral Codestral model and prepare it for use. This might take a few moments. Once it's done, we can move to the next step and configure Continue to use the `ollama` provider.

## Install and configure the Continue package in VS Code

With Ollama deployed, we will show how to configure Continue for VS Code to use `ollama` as a provider. For JetBrains, please refer to the [Continue documentation](https://docs.continue.dev/quickstart#jetbrains).

Get started by installing the [Continue VS Code extension](https://marketplace.visualstudio.com/items?itemName=Continue.continue).
This will open the Continue extension page for VS Code. Click the **Install** button to install the extension.

Once the install has completed, open the `~/.continue/config.json` file on your machine and edit it to match the format below:

```json
{
  "models": [
    {
      "title": "Codestral on Koyeb",
      "apiBase": "https://<YOUR_SUBDOMAIN>.koyeb.app/",
      "provider": "ollama",
      "model": "llama3:8b"
    }
  ]
}
```

The above configuration tells Continue to:

1. use the `ollama` provider
2. use the Mistral Codestral model
3. use the Ollama Instance located at the Koyeb Service URL

<Admonition>Take care to replace the `apiBase` value with your Ollama Service URL.</Admonition>

Restart VS Code to apply the changes and get started using the AI code assistant.

## Get started with your Custom AI code assistant

Use the following shortcuts to access Continue and interact with the AI code assistant:

- cmd+L (MacOS)
- ctrl-L (Windows / Linux)

You can now start asking questions about your codebase, get autocomplete suggestions, and more.

## Conclusion

In this guide, we demonstrated how to use Continue, Ollama, MistralAI's Codestral, and Koyeb GPUs to build a custom autocomplete and chat experience inside of VS Code.
This tutorial covers the basics of how to get started using Continue. To go further, be sure to check out the [Continue documentation](https://docs.continue.dev/intro)
to learn more about how to use Continue.