Package: openai-shell-craft
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.InstallationSee theWikifor installation instructions.Pip InstallationDocker InstallationCommand Line InterfaceShell Craft often follows the format of:shell-craft--prompt<type><request>You can use the following command to get started:shell-craft--helpSee theWikifor additional command line usage instructions.SeePrompt Typesfor a guide to the different--promptoptions.Python APIThe 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.importosfromshell_craft.servicesimportOpenAIService,OpenAISettingsfromshell_craft.promptsimportBASH_PROMPTresults=OpenAIService(OpenAISettings(api_key=os.environ.get("OPENAI_API_KEY"),model='gpt-3.5-turbo',count=1,temperature=0.0,messages=BASH_PROMPT.messages,)).query(message=input("Enter your request: "))print(results)API KeyShell 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 informationand 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 keyisyour responsibility.To obtain an API key from the OpenAI platform, follow these steps:Go tohttps://platform.openai.com/account/api-keysin 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, youmustpass it to Shell Craft viaoneof 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.jsonthe file named by $SHELLCRAFT_CONFIG$XDG_CONFIG_HOME/shell-craft/config.json$HOME/.config/shell-craft/config.jsonThe 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-keyAPI_KEYWhereAPI_KEYis your OpenAI API key.Option 3 - Environment Variable:exportOPENAI_API_KEY=<yoursecretkey>
shell-craft"list all files in directory"Where<your secret key>is your OpenAI API key.LicenseThis project is licensed under the MIT License - see theLICENSEfile for details.AcknowledgmentsAcknowledgments contain a few of the people who have helped the project along the way.OpenAIfor their language models and API.Joel Fourhmanfor the initial idea, the challenge, and the project name.Chase Montgomeryfor testing, feedback, and estimated time savings vs manual implementation.Bryan Gonzalezfor powershell feedback and merge reviews.Aaron Croissettefor business use case feedback, documentation, and a lovely PyPi icon on the readme.