Generating shell commands and code using natural language models (OpenAI ChatGPT).
Project description
Shell Craft
Generating shell commands and code using natural language models (OpenAI ChatGPT).
Shell Craft can:
- Generate shell commands from natural language requests.
- Write code in a dozen languages from natural language requests.
- Refactor existing code.
- Document existing code.
- Generate tests for existing code.
- Generate issue tickets and feature requests for GitHub, GitLab, and BitBucket.
Our goal is to 10x developer productivity by combining the power of natural language models with the power of the command line.
Installation
See the Wiki for installation instructions.
Command Line Interface
Shell Craft often follows the format of:
shell-craft --prompt <type> <request>
You can use the following command to get started:
shell-craft --help
See the Wiki for additional command line usage instructions.
See Prompt Types for a guide to the different --prompt
options.
Python API
The following example shows how to use Shell Craft inside of your own Python code. The example loads your api key from an environment variable, uses the Bash prompt, and gets input from the user.
import os
from shell_craft import Service
from shell_craft.prompts import BASH_PROMPT
Service(
api_key = os.environ.get("OPENAI_API_KEY"),
prompt = BASH_PROMPT,
).query(
message = input("Enter your request: ")
)
API Key
Shell Craft uses the OpenAI API to generate the shell commands, requiring an API key to give it access to an account with OpenAI.
Warning! API keys are sensitive information and should be kept confidential. Don't share your API key with anyone who shouldn't have access to it. Failure to do so may result in charges on your OpenAI account. Shell Craft never transmits this key to any service other than the official OpenAI API. Your API key is your responsibility.
To obtain an API key from the OpenAI platform, follow these steps:
- Go to https://platform.openai.com/account/api-keys in your web browser.
- Log in to your OpenAI account or create a new account if you don't have one.
- Click the "Create new secret key" button.
- Copy the key that is generated for you.
Once you have your API key, you must pass it to Shell Craft via one of the following methods.
Option 1 (Recommended) - Configuration file:
shell-craft looks for a configuration file in the following places, in order:
- the current directory, named config.json
- the file named by $SHELLCRAFT_CONFIG
- $XDG_CONFIG_HOME/shell-craft/config.json
- $HOME/.config/shell-craft/config.json
The contents are simple json:
{
"openai_api_key": "<your secret key>"
}
Now, Shell Craft will know your API key in order to run future prompts without having to specify it or ensure it exists in the environmental variables.
Option 2 - Command Line Argument:
shell-craft "list all files in directory" --api-key API_KEY
Where API_KEY
is your OpenAI API key.
Option 3 - Environment Variable:
export OPENAI_API_KEY=<your secret key>
shell-craft "list all files in directory"
Where <your secret key>
is your OpenAI API key.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Acknowledgments contain a few of the people who have helped the project along the way.
- OpenAI for their language models and API.
- Joel Fourhman for the initial idea, the challenge, and the project name.
- Chase Montgomery for testing, feedback, and estimated time savings vs manual implementation.
- Bryan Gonzalez for powershell feedback and merge reviews.
- Aaron Croissette for business use case feedback, documentation, and a lovely PyPi icon on the readme.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file openai_shell_craft-0.8.1.tar.gz
.
File metadata
- Download URL: openai_shell_craft-0.8.1.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86ccbae4e0380e4d586c85fcc07bf233940fc75789afa4f5fec1b8348ed80bcf |
|
MD5 | c1a03e69ad44311d6a578c3c5c09c375 |
|
BLAKE2b-256 | 571207fea4687b9b88f597e0c9227244b6e33ec38b96909e5e53c544dbe9e50b |
File details
Details for the file openai_shell_craft-0.8.1-py3-none-any.whl
.
File metadata
- Download URL: openai_shell_craft-0.8.1-py3-none-any.whl
- Upload date:
- Size: 30.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10d3492bd51d75098be6a5fbc954befdc8c99c9896de5983543cfeef4b348da8 |
|
MD5 | 669eb3f3ad728cd8db6e1c5f32806d30 |
|
BLAKE2b-256 | ffe883a6ff080cc807fbf70e9ccec28ac7702d21f062dacd4ff50e65e0ebe2cb |