Skip to main content

Creates shell command from a description using an LLM

Project description

nlshell

A very small Python package that generates shell commands from a "natural language" description. It will provide a explanation of the command and prefill the command line with the generated command.

You must provide a url to an openai compatible api, e.g. a local model served by e.g. Ollama, or a remote model.

IMPORTANT! Never run a generated command without understanding what it does. The generated command may be harmful. There is no guarantee whatsoever that what the LLM suggests is correct! DON'T BLINDLY TRUST THE GENERATED SUGGESTION!

Table of Contents

Installation

Instructions on how to install your package. Include both the pip and poetry methods.

# Using pip
pip install nlshell

# Using poetry
poetry add nlshell

Usage

Activate the virtual environment where the package is installed to use the nlshell command.

Set the base_url

The package uses the openai client to call an LLM. By specifying a base-url you can use your own model, e.g. a local model.

c --base-url http://localhost:11434/v1

If no base_url is explicitly set, the package will ask which url to use.

Create a command

c list all files in the current directory, including hidden files

where c is the nlshell command. This command will generate a response like this:

The 'ls' command lists directory contents. The option '-l' provides a long listing format which includes file permissions, number of links, owner, group, size, and time of last modification. The '-a' option ensures hidden files (those starting with a dot .) are also listed.
$ ls -la

Set the api_key

c --api-key your-api-key

Even if you run a local model you need to set an api_key since the openai client requires it, even if the key is just a dummy key.

Set the model

c --model-name qwen2.5-coder:7b

If no model is specified the package will ask which model to use.

License

Distributed under the MIT License. See LICENSE for more information.

GitHub

https://github.com/mbrycke/nlshell

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

nlshell-0.1.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

nlshell-0.1.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file nlshell-0.1.1.tar.gz.

File metadata

  • Download URL: nlshell-0.1.1.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.15 Linux/6.5.0-1025-azure

File hashes

Hashes for nlshell-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c16702d87d0d40900c9817f2119d5be7b96dbe15ca2559b34c8a0546f4acd5a4
MD5 caebfbaf2cc9545df310c47af70fc50d
BLAKE2b-256 8e6d84f53e8fc0b0b77a07ac12d71e4d77b60782c90235d7d765caa7965a42ad

See more details on using hashes here.

File details

Details for the file nlshell-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: nlshell-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.15 Linux/6.5.0-1025-azure

File hashes

Hashes for nlshell-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9c115cb1aea450be743122b4def99c2142667b6b142240016f6c1472f752ff9e
MD5 748fd3fef1e7a393ab2baf8e2171f7f3
BLAKE2b-256 baae97b1dcd5887d172610e42b33d0434de74b6645a8dceb8515f4d5114a490a

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