Codestral [Part 2]: Enhancing Developer Productivity with Codestral in VSCode

Mouez Yazidi
4 min readJun 5, 2024

--

Introduction

In the fast-paced world of software development, every second matters. Developers are always on the lookout for tools and techniques to streamline their workflow, boost productivity, and reduce errors. One such tool is Codestral — an AI-powered code assistant that integrates seamlessly with Visual Studio Code (VSCode). This blog post will walk you through integrating Codestral into VSCode, highlight its benefits, and provide tips on maximizing its utility in your daily development tasks. For more details about Codestral, refer to the first part of this series.

Please note that this article assumes you have vscode installed. If not, you can follow installation guides VsCode.

1. Download Continue VSCode extension

The Continue extension for Visual Studio Code enables you to create your own AI code assistant inside your IDE. It keeps developers in flow by connecting to open-source models and providing autocompletions, code understanding, and even the ability to ask questions about your codebase. You can find it on the Visual Studio Marketplace and explore its features!

Once the installation is complete, you will see the Continue icon appear on the left side of the VSCode interface.

2. Connect VSCode with Codestral via API

You have two options to connect VSCode with Codestral. The first option is to run Codestral locally, and the second option is to use the official API. In this tutorial, we will choose the second option to work directly with the API.

To access Codestral via API, you’ll need an API key. Follow these steps:

  • Create a Mistral AI account.
  • Log in to your Mistral AI account.
  • Navigate to your account settings.
  • Click on ‘Codestral.’
  • Generate a new API key.

Afterward, you’ll need to configure the API key in Visual Studio Code. Follow these steps:

  • Open the contenue extension and click ‘+’ to add a new model.
  • Choose Mistral API option
  • Paste your API key in the field and select codestral as the model.

3. Use codestral as coding assistant in vscode

In this section, we will test scenarios to demonstrate how Codestral can improve the productivity.

a. code generation

Let’s create a simple Python function using Codestral. Imagine we want to generate a function that calculates the factorial of a given positive integer. Here’s how you can do it:

b. Code explanation:

Let’s use the Codestral to analyze a Python script. Suppose we have the following script that calculates the Fibonacci sequence:

def fibonacci(n):
if n <= 1:
return n
else:
return fibonacci(n - 1) + fibonacci(n - 2)

print(fibonacci(5))

c. fix code errors

in this scenario, we gonna make same errros in the script and let codestral model fix it

Conclusion

In conclusion, Codestral is a powerful and versatile extension for Visual Studio Code that can greatly enhance the productivity and efficiency of developers. By providing features such as code snippets, code formatting, and error highlighting, Codestral can help developers write cleaner, more accurate code with ease. Additionally, the extension’s customization options and support for multiple programming languages make it a valuable tool for developers working on a wide range of projects. Overall, incorporating Codestral into your VSCode workflow is a smart choice for any developer looking to streamline their coding process and produce high-quality results.

--

--