Skip to main content

Interface to interact with a chatbot in Linux terminal

Project description

MistralTerminal - chatbot in your Linux terminal

Overview

MistralTerminal is a command-line interface for interacting with MistralAI. It allows users to send questions directly from the terminal and receive concise answers from MistralAI. This script is designed for simplicity and ease of use. It keeps the conversation history, so you can continue interact with it without giving the context every time. The input can be multiline. If the script suggest code blocks, you can easily copy them in the clipboard. It also supports colored output for enhanced readability.

License

License: BSD 3 clause

Author

V.A. Yastrebov, CNRS, MINES Paris - PSL, France, Jan 2024.

External Contributors

Requirements

Installation

Set your MistralAI API key in your environment:

export MISTRAL_API_KEY='your_api_key_here'

From Github sources

git clone https://github.com/vyastreb/ai-terminal.git
cd ai-terminal

Install required dependencies and the ai command using :

pip install .

From PyPi

Comming Soon

Options

  • --model/-m: Sets the MistralAI model to be used (mistral-tiny, mistral-small or mistral-medium). Default is 'mistral-tiny'.
  • --temp/-T: Sets the temperature for the AI's responses. Default is 0.2.
  • --tokens/-t: Sets the maximum number of tokens in the response. Default is 2.
  • --verbose/-v: If set, prints the question or the whole history.
  • --no-chat/-n: If set, does not keep the discussion in memory.
  • --unit-test/-u: Unit tests.
  • --help/-h: Displays the help message and usage instructions.

The default model is 'mistral-tiny', which is a smaller model that is faster to load and run. The default temperature is 0.5, which is a good value for most questions. The default token count is 350, which is a reasonable length for most answers. The verbose option is useful for checking whether your questions and history were correctly parsed by the script.

Configuration file

All parameters could be defined in the script or in the config file ~/.mistralai/config.json. If config file is not found, the script will use default parameters. If config file exists, it will use parameters from the file, and will ignore parameters defined in the script. But if you prescribe options in the command line, they will be used instead of the config file.

Example of config file:

{
 "model": "mistral-tiny",
 "max_memory": 31,
 "max_tokens": 1000,
 "waitingTime": 180,
 "max_line_length": 80,
 "temperature": 0.5
}

Usage

ai [options]

These commands will start a new line > where your question could be written.

Examples:

ai
> How to convert jpg to png in linux?
ai --temp 0.0
> What is the meaning of life?
ai --model mistral-tiny --temp 0.8 --tokens 5000
> What is the best (according to parisian) cheese in France?
ai -m mistral-small -T 0.8 -t 500 -v
> What is the visible EM spectrum?

Features

  • Can be run from anywhere in the terminal
  • Supports multi-line input
  • Remembers past questions
  • If one code block is shown, it automatically stores it in the clipboard
  • If several code blocks are shown, it suggests to store the one you want in the clipboard
  • Keeps the history of conversation in a local file for some (user defined) time
  • Colored output for enhanced readability
  • Adjustable parameters for model, temperature, and token count
  • Supports multi-line responses with automatic line wrapping

Notes

  • Ensure your terminal supports ANSI color codes for the best experience.
  • The history of last messages (31 by default) is stored in ~/.mistralai/history.txt for 3 minutes by default. You can change the number of stored messages and the time in the script of in config file: max_memory and waitingTime.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai-terminal-0.1.0rc1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_terminal-0.1.0rc1-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file ai-terminal-0.1.0rc1.tar.gz.

File metadata

  • Download URL: ai-terminal-0.1.0rc1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.1

File hashes

Hashes for ai-terminal-0.1.0rc1.tar.gz
Algorithm Hash digest
SHA256 3fcf188df383005fb032ffe0c0d7cbc72807524293d01f473284326a75dd00c3
MD5 be0c25e6a779c3faec344b2477dfc239
BLAKE2b-256 558507d0335c3356664a639db20f341080e806a1225a9e4ee8566f6e4a95a94c

See more details on using hashes here.

File details

Details for the file ai_terminal-0.1.0rc1-py3-none-any.whl.

File metadata

  • Download URL: ai_terminal-0.1.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.1

File hashes

Hashes for ai_terminal-0.1.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 e4431cba12d49fe662b34157e568e239307af40556ccb4f7b762297a477d3369
MD5 6e1368427401f50efcb47d83deca572f
BLAKE2b-256 41afd60273b4c0d8a18135e64fda9ac6307da7e07098078a54267c17ebe520ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page