llm2sh


Namellm2sh JSON
Version 0.3.7 PyPI version JSON
download
home_pageNone
SummaryAsk GPT to run a command
upload_time2024-08-31 04:16:16
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseGPL-3.0
keywords llm gpt cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # llm2sh

`llm2sh` is a command-line utility that leverages Large Language Models (LLMs) to translate plain-language requests
into shell commands. It provides a convenient way to interact with your system using natural language.

## Features

- Translates plain language requests into corresponding shell commands
- Supports multiple LLMs for command generation
- Customizable configuration file
- YOLO mode for running commands without confirmation
- Easily extensible with new LLMs and system prompts
- Verbose mode for debugging

## Installation

```bash
pip install llm2sh
```

## Usage

`llm2sh` uses OpenAI, Claude, and other LLM APIs to generate shell commands based on the user's requests.
For OpenAI, Claude, and Groq, you will need to have an API key to use this tool.

- OpenAI: You can sign up for an API key on the [OpenAI website](https://platform.openai.com/).
- Claude: You can sign up for an API key on the [Claude API Console](https://console.anthropic.com/dashboard).
- Groq: You can sign up for an API key on the [GroqCloud Console](https://console.groq.com/).
- Cerebras: You can sign up for an API key on the [Cerebras Developer Platform](https://cloud.cerebras.ai/).

### Configuration

Running `llm2sh` for the first time will create a template configuration file at `~/.config/llm2sh/llm2sh.json`.
You can specify a different path using the `-c` or `--config` option.

Before using `llm2sh`, you need to set up the configuration file with your API keys and preferences.
You can also use the `OPENAI_API_KEY`, `CLAUDE_API_KEY`, and `GROQ_API_KEY` environment variables to specify the
API keys.

### Basic Usage

To use `llm2sh`, run the following command followed by your request:

```bash
llm2sh [options] <request>
```

**For example:**

1. Basic usage:

```bash
$ llm2sh "list all files in the current directory"

You are about to run the following commands:
  $ ls -a
Run the above commands? [y/N]
```

2. Use a specific model for command generation:

```bash
$ llm2sh -m gpt-3.5-turbo "find all Python files in the current directory, recursively"

You are about to run the following commands:
  $ find . -type f -name "*.py"
Run the above commands? [y/N]
```

3. `llm2sh` supports running multiple commands in sequence, and supports interactive commands like `sudo`:

```bash
llm2sh "install docker in rootless mode"

You are about to run the following commands:
  $ sudo newgrp docker
  $ sudo pacman -Sy docker-rootless-extras
  $ sudo usermod -aG docker "$USERNAME"
  $ dockerd-rootless-setuptool.sh install
Run the above commands? [y/N]
```

4. Run the generated command without confirmation:

```bash
llm2sh --force "delete all temporary files"
```

### Options

```text
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
                        specify config file, (Default: ~/.config/llm2sh/llm2sh.json)
  -d, --dry-run         do not run the generated command
  -l, --list-models     list available models
  -m MODEL, --model MODEL
                        specify which model to use
  -t TEMPERATURE, --temperature TEMPERATURE
                        use a custom sampling temperature
  -v, --verbose         print verbose debug information
  -f, --yolo, --force   run whatever GPT wants, without confirmation
```

## Supported Models

`llm2sh` currently supports the following LLMs for command generation:

(Ratings are based on my subjective opinion and experience. Your mileage may vary.)

| Model Name | Provider | Accuracy | Cost | Notes |
|----------|----------|----------|----------|----------|
| `local` | N/A | ¯\\_(ツ)_/¯ | **FREE** | Needs local OpenAI API compatible LLM Api Endpoint (i.e. llama.cpp) |
| `groq-llama3-70b` | Groq | 🧠🧠🧠 | **FREE** _(with rate limits)_ | Blazing fast; recommended |
| `groq-llama3-8b` | Groq | 🧠🧠 | **FREE** _(with rate limits)_ | Blazing fast |
| `groq-mixtral-8x7b` | Groq | 🧠 | **FREE** _(with rate limits)_ | Blazing fast |
| `groq-gemma-7b` | Groq | 🧠 | **FREE** _(with rate limits)_ | Blazing fast |
| `cerebras-llama3-70b` | Cerebras | 🧠🧠🧠 | **FREE** _(with rate limits)_ | Blazing fast; recommended |
| `cerebras-llama3-8b` | Cerebras | 🧠🧠 | **FREE** _(with rate limits)_ | Blazing fast |
| `gpt-4o` | OpenAI | 🧠🧠 | 💲💲💲 | Default model |
| `gpt-4-turbo` | OpenAI | 🧠🧠🧠 | 💲💲💲💲 | |
| `gpt-3.5-turbo-instruct` | OpenAI | 🧠🧠 | 💲💲 | |
| `claude-3-opus` | Claude | 🧠🧠🧠🧠 | 💲💲💲💲 | Fairly slow (>10s) |
| `claude-3-sonnet` | Claude | 🧠🧠🧠 | 💲💲💲 | Somewhat slow (~5s) |
| `claude-3-haiku` | Claude | 🧠 | 💲💲 | |

## Roadmap

- ✅ Support multiple LLMs for command generation
- ⬜ User-customizable system prompts
- ⬜ Integrate with tool calling for more complex commands
- ⬜ More complex RAG for efficiently providing relevant context to the LLM
- ⬜ Better support for executing complex interactive commands
- ⬜ Interactive configuration & setup via the command line

## Privacy

`llm2sh` does not store any user data or command history, and it does not record or send any telemetry
by itself. However, the LLM APIs may collect and store the requests and responses for their own purposes.

To help LLMs generate better commands, `llm2sh` may send the following information as part of the LLM
prompt in addition to the user's request:

- Your operating system and version
- The current working directory
- Your username
- Names of files and directories in your current working directory
- Names of environment variables available in your shell. (Only the names/keys are sent, not the values).

## Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the [GitHub repository](https://github.com/randombk/llm2sh).

## License

This project is licensed under the [GPLv3](LICENSE).

## Disclaimer

`llm2sh` is an experimental tool that relies on LLMs for generating shell commands. While it can be helpful, it's important to review and understand the generated commands before executing them, especially when using the YOLO mode. The developers are not responsible for any damages or unintended consequences resulting from the use of this tool.

This project is not affiliated with OpenAI, Claude, or any other LLM provider or creator.
This project is not affiliated with my employer in any way. It is an independent project created for educational and research purposes.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "llm2sh",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "llm, gpt, cli",
    "author": null,
    "author_email": "David Li <david@david-li.com>",
    "download_url": "https://files.pythonhosted.org/packages/89/eb/11d799ee799bb45f562c0b09aee087f1074f2c3924c4879ffa651a930630/llm2sh-0.3.7.tar.gz",
    "platform": null,
    "description": "# llm2sh\n\n`llm2sh` is a command-line utility that leverages Large Language Models (LLMs) to translate plain-language requests\ninto shell commands. It provides a convenient way to interact with your system using natural language.\n\n## Features\n\n- Translates plain language requests into corresponding shell commands\n- Supports multiple LLMs for command generation\n- Customizable configuration file\n- YOLO mode for running commands without confirmation\n- Easily extensible with new LLMs and system prompts\n- Verbose mode for debugging\n\n## Installation\n\n```bash\npip install llm2sh\n```\n\n## Usage\n\n`llm2sh` uses OpenAI, Claude, and other LLM APIs to generate shell commands based on the user's requests.\nFor OpenAI, Claude, and Groq, you will need to have an API key to use this tool.\n\n- OpenAI: You can sign up for an API key on the [OpenAI website](https://platform.openai.com/).\n- Claude: You can sign up for an API key on the [Claude API Console](https://console.anthropic.com/dashboard).\n- Groq: You can sign up for an API key on the [GroqCloud Console](https://console.groq.com/).\n- Cerebras: You can sign up for an API key on the [Cerebras Developer Platform](https://cloud.cerebras.ai/).\n\n### Configuration\n\nRunning `llm2sh` for the first time will create a template configuration file at `~/.config/llm2sh/llm2sh.json`.\nYou can specify a different path using the `-c` or `--config` option.\n\nBefore using `llm2sh`, you need to set up the configuration file with your API keys and preferences.\nYou can also use the `OPENAI_API_KEY`, `CLAUDE_API_KEY`, and `GROQ_API_KEY` environment variables to specify the\nAPI keys.\n\n### Basic Usage\n\nTo use `llm2sh`, run the following command followed by your request:\n\n```bash\nllm2sh [options] <request>\n```\n\n**For example:**\n\n1. Basic usage:\n\n```bash\n$ llm2sh \"list all files in the current directory\"\n\nYou are about to run the following commands:\n  $ ls -a\nRun the above commands? [y/N]\n```\n\n2. Use a specific model for command generation:\n\n```bash\n$ llm2sh -m gpt-3.5-turbo \"find all Python files in the current directory, recursively\"\n\nYou are about to run the following commands:\n  $ find . -type f -name \"*.py\"\nRun the above commands? [y/N]\n```\n\n3. `llm2sh` supports running multiple commands in sequence, and supports interactive commands like `sudo`:\n\n```bash\nllm2sh \"install docker in rootless mode\"\n\nYou are about to run the following commands:\n  $ sudo newgrp docker\n  $ sudo pacman -Sy docker-rootless-extras\n  $ sudo usermod -aG docker \"$USERNAME\"\n  $ dockerd-rootless-setuptool.sh install\nRun the above commands? [y/N]\n```\n\n4. Run the generated command without confirmation:\n\n```bash\nllm2sh --force \"delete all temporary files\"\n```\n\n### Options\n\n```text\n  -h, --help            show this help message and exit\n  -c CONFIG, --config CONFIG\n                        specify config file, (Default: ~/.config/llm2sh/llm2sh.json)\n  -d, --dry-run         do not run the generated command\n  -l, --list-models     list available models\n  -m MODEL, --model MODEL\n                        specify which model to use\n  -t TEMPERATURE, --temperature TEMPERATURE\n                        use a custom sampling temperature\n  -v, --verbose         print verbose debug information\n  -f, --yolo, --force   run whatever GPT wants, without confirmation\n```\n\n## Supported Models\n\n`llm2sh` currently supports the following LLMs for command generation:\n\n(Ratings are based on my subjective opinion and experience. Your mileage may vary.)\n\n| Model Name | Provider | Accuracy | Cost | Notes |\n|----------|----------|----------|----------|----------|\n| `local` | N/A | \u00af\\\\_(\u30c4)_/\u00af | **FREE** | Needs local OpenAI API compatible LLM Api Endpoint (i.e. llama.cpp) |\n| `groq-llama3-70b` | Groq | \ud83e\udde0\ud83e\udde0\ud83e\udde0 | **FREE** _(with rate limits)_ | Blazing fast; recommended |\n| `groq-llama3-8b` | Groq | \ud83e\udde0\ud83e\udde0 | **FREE** _(with rate limits)_ | Blazing fast |\n| `groq-mixtral-8x7b` | Groq | \ud83e\udde0 | **FREE** _(with rate limits)_ | Blazing fast |\n| `groq-gemma-7b` | Groq | \ud83e\udde0 | **FREE** _(with rate limits)_ | Blazing fast |\n| `cerebras-llama3-70b` | Cerebras | \ud83e\udde0\ud83e\udde0\ud83e\udde0 | **FREE** _(with rate limits)_ | Blazing fast; recommended |\n| `cerebras-llama3-8b` | Cerebras | \ud83e\udde0\ud83e\udde0 | **FREE** _(with rate limits)_ | Blazing fast |\n| `gpt-4o` | OpenAI | \ud83e\udde0\ud83e\udde0 | \ud83d\udcb2\ud83d\udcb2\ud83d\udcb2 | Default model |\n| `gpt-4-turbo` | OpenAI | \ud83e\udde0\ud83e\udde0\ud83e\udde0 | \ud83d\udcb2\ud83d\udcb2\ud83d\udcb2\ud83d\udcb2 | |\n| `gpt-3.5-turbo-instruct` | OpenAI | \ud83e\udde0\ud83e\udde0 | \ud83d\udcb2\ud83d\udcb2 | |\n| `claude-3-opus` | Claude | \ud83e\udde0\ud83e\udde0\ud83e\udde0\ud83e\udde0 | \ud83d\udcb2\ud83d\udcb2\ud83d\udcb2\ud83d\udcb2 | Fairly slow (>10s) |\n| `claude-3-sonnet` | Claude | \ud83e\udde0\ud83e\udde0\ud83e\udde0 | \ud83d\udcb2\ud83d\udcb2\ud83d\udcb2 | Somewhat slow (~5s) |\n| `claude-3-haiku` | Claude | \ud83e\udde0 | \ud83d\udcb2\ud83d\udcb2 | |\n\n## Roadmap\n\n- \u2705 Support multiple LLMs for command generation\n- \u2b1c User-customizable system prompts\n- \u2b1c Integrate with tool calling for more complex commands\n- \u2b1c More complex RAG for efficiently providing relevant context to the LLM\n- \u2b1c Better support for executing complex interactive commands\n- \u2b1c Interactive configuration & setup via the command line\n\n## Privacy\n\n`llm2sh` does not store any user data or command history, and it does not record or send any telemetry\nby itself. However, the LLM APIs may collect and store the requests and responses for their own purposes.\n\nTo help LLMs generate better commands, `llm2sh` may send the following information as part of the LLM\nprompt in addition to the user's request:\n\n- Your operating system and version\n- The current working directory\n- Your username\n- Names of files and directories in your current working directory\n- Names of environment variables available in your shell. (Only the names/keys are sent, not the values).\n\n## Contributing\n\nContributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the [GitHub repository](https://github.com/randombk/llm2sh).\n\n## License\n\nThis project is licensed under the [GPLv3](LICENSE).\n\n## Disclaimer\n\n`llm2sh` is an experimental tool that relies on LLMs for generating shell commands. While it can be helpful, it's important to review and understand the generated commands before executing them, especially when using the YOLO mode. The developers are not responsible for any damages or unintended consequences resulting from the use of this tool.\n\nThis project is not affiliated with OpenAI, Claude, or any other LLM provider or creator.\nThis project is not affiliated with my employer in any way. It is an independent project created for educational and research purposes.\n",
    "bugtrack_url": null,
    "license": "GPL-3.0",
    "summary": "Ask GPT to run a command",
    "version": "0.3.7",
    "project_urls": {
        "Changelog": "https://github.com/randombk/llm2sh/blob/master/.version",
        "Source": "https://github.com/randombk/llm2sh",
        "Tracker": "https://github.com/randombk/llm2sh/issues"
    },
    "split_keywords": [
        "llm",
        " gpt",
        " cli"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "89eb11d799ee799bb45f562c0b09aee087f1074f2c3924c4879ffa651a930630",
                "md5": "d0efa4633bb35d082821be4f9e328dcf",
                "sha256": "9a4ce428102f9f52cf45383666d45bbf638559bbd912e91402871105c2650a15"
            },
            "downloads": -1,
            "filename": "llm2sh-0.3.7.tar.gz",
            "has_sig": false,
            "md5_digest": "d0efa4633bb35d082821be4f9e328dcf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 26018,
            "upload_time": "2024-08-31T04:16:16",
            "upload_time_iso_8601": "2024-08-31T04:16:16.219188Z",
            "url": "https://files.pythonhosted.org/packages/89/eb/11d799ee799bb45f562c0b09aee087f1074f2c3924c4879ffa651a930630/llm2sh-0.3.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-31 04:16:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "randombk",
    "github_project": "llm2sh",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "llm2sh"
}
        
Elapsed time: 0.80201s