Skip to main content

No project description provided

Project description

Shell-AI: let AI write your shell commands

PyPI version License: MIT Forks Stars

Shell-AI (shai) is a CLI utility that brings the power of natural language understanding to your command line. Simply input what you want to do in natural language, and shai will suggest single-line commands that achieve your intent. Under the hood, Shell-AI leverages the LangChain for LLM use and builds on the excellent InquirerPy for the interactive CLI.

demo-shell-ai

Installation

You can install Shell-AI directly from PyPI using pip:

pip install shell-ai

Note that on Linux, Python 3.10 or later is required.

After installation, you can invoke the utility using the shai command.

Usage

To use Shell-AI, open your terminal and type:

shai run terraform dry run thingy

Shell-AI will then suggest 3 commands to fulfill your request:

  • terraform plan
  • terraform plan -input=false
  • terraform plan

Features

  • Natural Language Input: Describe what you want to do in plain English (or other supported languages).
  • Command Suggestions: Get single-line command suggestions that accomplish what you asked for.
  • Cross-Platform: Works on Linux, macOS, and Windows.
  • Azure Compatibility: Shell-AI now supports Azure OpenAI deployments.

Configuration

Environment Variables

  1. OPENAI_API_KEY: Required. Set this environment variable to your OpenAI API key. You can find it on your OpenAI Dashboard.

Optional Variables

  1. OPENAI_MODEL: Defaults to gpt-3.5-turbo. You can set it to another OpenAI model if desired.
  2. OPENAI_MAX_TOKENS: Defaults to None. You can set the maximum number of tokens that can be generated in the chat completion.
  3. SHAI_SUGGESTION_COUNT: Defaults to 3. You can set it to specify the number of suggestions to generate.
  4. OPENAI_API_BASE: Defaults to https://api.openai.com/v1. You can set it to specify the proxy or service emulator.
  5. OPENAI_ORGANIZATION: OpenAI Organization ID
  6. OPENAI_PROXY: OpenAI proxy
  7. OPENAI_API_TYPE: Set to "azure" if you are using Azure deployments.
  8. AZURE_DEPLOYMENT_NAME: Your Azure deployment name (required if using Azure).
  9. AZURE_API_BASE: Your Azure API base (required if using Azure).
  10. CTX: Allow the assistant to keep the console outputs as context allowing the LLM to produce more precise outputs. IMPORTANT: the outputs will be sent to OpenAI through their API, be careful if any sensitive data. Default to false.

You can also enable context mode in command line with --ctx flag:

shai --ctx [request]

Configuration File

Alternatively, you can store these variables in a JSON configuration file:

  • For Linux/macOS: Create a file called config.json under ~/.config/shell-ai/ and secure it with chmod 600 ~/.config/shell-ai/config.json.
  • For Windows: Create a file called config.json under %APPDATA%\shell-ai\

Example config.json:

{
  "OPENAI_API_KEY": "your_openai_api_key_here",
  "OPENAI_MODEL": "gpt-3.5-turbo",
  "SHAI_SUGGESTION_COUNT": "3",
  "CTX": true
}

The application will read from this file if it exists, overriding any existing environment variables.

Run the application after setting these configurations.

Contributing

This implementation can be made much smarter! Contribute your ideas as Pull Requests and make AI Shell better for everyone.

Contributions are welcome! Please read the CONTRIBUTING.md for guidelines.

License

Shell-AI is licensed under the MIT License. See LICENSE for details.

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

shell_ai-0.3.26.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

shell_ai-0.3.26-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file shell_ai-0.3.26.tar.gz.

File metadata

  • Download URL: shell_ai-0.3.26.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for shell_ai-0.3.26.tar.gz
Algorithm Hash digest
SHA256 401b31f545098724b0232a51e313a5937ff0147346431d26dfc50048cf773275
MD5 db30ffe45c06238f60f982a95aaa4f5a
BLAKE2b-256 ce653e9c245625c23917b3fc9fe4518f2efdb563c0d7d0f9f7f32c1e3d15f84d

See more details on using hashes here.

File details

Details for the file shell_ai-0.3.26-py3-none-any.whl.

File metadata

  • Download URL: shell_ai-0.3.26-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for shell_ai-0.3.26-py3-none-any.whl
Algorithm Hash digest
SHA256 c22b21111bea9471b2af775ff1a4e44fbec49e9e848b49a24214a9f9805aaae9
MD5 dc8640618cbba76027ff7bd002fbe596
BLAKE2b-256 1d245264a3b78fd6f9412150ce5f5e371937b0272949dad46402187358a93a6e

See more details on using hashes here.

Supported by

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