Mentat: The AI Coding Assistant

1 min


Mentat

Mentat

The AI Coding Assistant

Github logo

Mentat is an AI-powered coding assistant that helps you with any programming task, directly from your terminal.

Mentat is different from other tools like Copilot or ChatGPT. It can make changes across multiple files and locations, without losing track of your project’s context. You don’t need to copy and paste anything – just ask Mentat what you want to do and it will do it for you!

Mentat Setup

Install Mentat

A virtual environment is a way to isolate your Python project from other packages and dependencies. It is recommended that you create one before installing this package, to avoid any conflicts or errors.

# Python 3.10 or higher is required
python3 -m venv .venv
source .venv/bin/activate

Note that you’ll have to have activated the virtual environment to run mentat if you install it there.

You have three options for installing the program. The first two are simple and will only allow you to execute it:

  • PyPI: python -m pip install mentat-ai
  • Github: python -m pip install git+https://github.com/biobootloader/mentat.git

If you want to make changes to Mentat’s code and run it, the third option is helpful:

git clone https://github.com/biobootloader/mentat.git
cd mentat

# install with pip in editable mode:
pip install -e .

Add your OpenAI API Key

Mentat requires API access to GPT-4 in order to function. You can choose from several methods to give Mentat your OpenAI API key:

  1. Start by creating an .env file with the line OPENAI_API_KEY=<your-api-key> in the directory you plan to run mentat in or in ~/.mentat/.env
  2. Then, run export OPENAI_API_KEY=<your key here> prior to running Mentat
  3. Now place the previous command in your .bashrc or .zshrc To export your key during every terminal startup.

Configuration

To change the default configuration of Mentat, you need to create ~/.mentat/config.json and add the fields you want to change.

Options

Allow 32k


Allow Mentat to use OpenAI’s gpt-4 32k context window model. Your API key must already have access to the model.

{
    "allow-32k": true
}

Filetype Include and Exclude list

When providing Mentat with a directory, you can specify which file types should be automatically included or excluded from the context. Please note that this setting will not apply to hidden files, ignored files, or files with a specific direct path.

{
    "filetype-include-list": [".include_this"],
    "filetype-exclude-list": [".exclude_this"]
}

File Exclude Glob list

Here is a list of glob patterns that will exclude any files that match them, starting from the specified directory.

{
    "file-exclude-glob-list": ["**/exclude_this.*"]
}

Input Style

Here is a list of key-value pairs that define a custom Pygment Style for styling the Mentat prompt.

{
    "input-style": [
        [
            "",
            "#9835bd"
        ],
        [
            "prompt",
            "#ffffff bold"
        ],
        [
            "continuation",
            "#ffffff bold"
        ]
    ]
}

🚀 Mentat Usage

Run Mentat using:

mentat <paths to files or directories>

If you give Mentat a directory, it will include all visible text files in that directory in its context. If this goes beyond the token context limit of GPT-4, you can try using Mentat with only the necessary files.

It is by will alone I set my mind in motion

The Mentat Mantra

Join Guidady AI Mail List

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.


Like it? Share with your friends!

0
62 shares

0 Comments

Your email address will not be published. Required fields are marked *

Belmechri

I am an IT engineer, content creator, and proud father with a passion for innovation and excellence. In both my personal and professional life, I strive for excellence and am committed to finding innovative solutions to complex problems.
Choose A Format
Personality quiz
Series of questions that intends to reveal something about the personality
Trivia quiz
Series of questions with right and wrong answers that intends to check knowledge
Poll
Voting to make decisions or determine opinions
Story
Formatted Text with Embeds and Visuals
List
The Classic Internet Listicles
Countdown
The Classic Internet Countdowns
Open List
Submit your own item and vote up for the best submission
Ranked List
Upvote or downvote to decide the best list item
Meme
Upload your own images to make custom memes
Video
Youtube and Vimeo Embeds
Audio
Soundcloud or Mixcloud Embeds
Image
Photo or GIF
Gif
GIF format