shell_gpt

A command-line productivity tool powered by AI large language models like GPT-4, will help you accomplish your tasks faster and more efficiently.

MIT License

Downloads
10.7K
Stars
9.5K
Committers
30

Bot releases are hidden (Show)

shell_gpt - 1.4.4 Latest Release

Published by TheR1D 2 months ago

What's Changed

New Contributors

Full Changelog: https://github.com/TheR1D/shell_gpt/compare/1.4.3...1.4.4

shell_gpt - 1.4.0

Published by TheR1D 8 months ago

What's Changed

  • Added new option โ€”md and โ€”no-md to disable or enable markdown output.
  • Added new config variable PRETTIFY_MARKDOWN to disable or enable markdown output by default.
  • Added new config variable USE_LITELLM to enforce usage of LiteLLM library.

OpenAI and LiteLLM

Because LiteLLM facilitates requests for numerous other LLM backends, it is heavy to import, adding 1-2 seconds of runtime. ShellGPT, by default will use OpenAI's library, which is suitable for most users. Optionally, ShellGPT can be installed with LiteLLM by running pip install shell-gpt[litellm]. To enforce LiteLLM usage set USE_LITELLM to true in the config file ~/.config/shell_gpt/.sgptrc.

shell_gpt - 1.3.1

Published by TheR1D 8 months ago

What's Changed

Full Changelog: https://github.com/TheR1D/shell_gpt/compare/1.3.0...1.3.1

shell_gpt - 1.3.0

Published by TheR1D 8 months ago

What's Changed

  • Ollama and other LLM backends.
  • Markdown formatting now depends on role description.
  • Code refactoring and optimisation.

Multiple LLM backends

ShellGPT now can work with multiple Backends using LiteLLM. You can use locally hosted open source models which are available for free. To use local models, you will need to run your own LLM backend server such as Ollama. To setup ShellGPT with Ollama, please follow this comprehensive guide. Full list of supported models and providers here. Note that ShellGPT is not optimized for local models and may not work as expectedโ—๏ธ

Markdown formatting

Markdown formatting now depends on the role description. For instance, if the role includes "APPLY MARKDOWN" in its description, the output for this role will be Markdown-formatted. This applies to both default and custom roles. If you would like to disable Markdown formatting, edit the default role description in ~/.config/shell_gpt/roles.

Full Changelog: https://github.com/TheR1D/shell_gpt/compare/1.2.0...1.3.0

shell_gpt - 1.2.0

Published by TheR1D 9 months ago

  • Added --interaction that works with --shell option, e.g. sgpt --shell --no-interaction will output suggested command to stdout. This is usefull when you want to redirect output to somewhere else. For instance sgpt -s "say hi" | pbcopy.
  • Fixed issue with stdin and --shell not switching to interactive input mode.
  • REPL mode now can accept stdin or PROMPT argument, or both.
  • Changed shell integrations to use new --no-interaction to generate shell commands.
  • Moved shell integrations into dedicated file integration.py.
  • Changed --install-integration logic, will not download sh script anymore.
  • Removed validation for PROMPT argument, now will be empty string by default.
  • Fixing an issue when sgpt is being called from non-interactive shell environments such as cron tab.
  • Fixed and optimised Dockerfile.
  • GitHub codespaces setup.
  • Improved tests.
  • README.md improvements.
  • New demo video ๐Ÿด.

โ—๏ธShell integration logic has been updated, and it will not work with previous version of integration function in ~/.bashrc or ~/.zshrc. Run sgpt --install-integration to apply new changes, and remove old integration function from your shell profile if you were using it before.

https://github.com/TheR1D/shell_gpt/assets/16740832/9197283c-db6a-4b46-bfea-3eb776dd9093

REPL stdin

REPL mode can now accept stdin, a PROMPT argument, or even both. This is useful when you want to provide some initial context for your prompt.

sgpt --repl temp < my_app.py
Entering REPL mode, press Ctrl+C to exit.
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Input โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
name = input("What is your name?")
print(f"Hello {name}")
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
>>> What is this code about?
The snippet of code you've provided is written in Python. It prompts the user...
>>> Follow up questions...

It is also possible to pass PROMPT to REPL mode sgpt --repl temp "some initial prompt" or even both sgpt --repl temp "initial arg prompt" < text.txt.

Full Changelog: https://github.com/TheR1D/shell_gpt/compare/1.1.0...1.2.0

shell_gpt - 1.1.0

Published by TheR1D 9 months ago

https://github.com/TheR1D/shell_gpt/assets/16740832/721ddb19-97e7-428f-a0ee-107d027ddd59

OpenAI Library

ShellGPT has now integrated the OpenAI Python library for handling API requests. This integration simplifies the development and maintenance of the ShellGPT code base. Additionally, it enhances user experience by providing more user-friendly error messages, complete with descriptions and potential solutions.

Function Calling

Function calls is a powerful feature OpenAI provides. It allows LLM to execute functions in your system, which can be used to accomplish a variety of tasks. ShellGPT has a convenient way to define functions and use them. To install default functions run:

sgpt --install-functions

This will add a function for LLM to execute shell commands and to execute Apple Scripts (on macOS). More details in demo video and README.md.

Options

  • Shortcut option -c for โ€”code.
  • Shortcut option -lc for --list-chats
  • Shortcut option -lr for --list-roles
  • New โ€”functions option, enables/disable function calling.
  • New โ€”install-functions option, installs default functions.

Config

  • New config variable OPENAI_FUNCTIONS_PATH
  • New config variable OPENAI_USE_FUNCTIONS
  • New config variable SHOW_FUNCTIONS_OUTPUT

Minor Changes

  • Code optimisation
  • Cache optimisations for function calls
shell_gpt - 1.0.1

Published by TheR1D 10 months ago

  • Fixed a bug in REPL mode which was not working properly since last release.
  • Minor optimisation and bug fixes in default roles.
  • Minor code optimisations.
shell_gpt - 1.0.0

Published by TheR1D 10 months ago

ShellGPT v1.0.0 release includes multiple significant changes:

  • Default model has been changed to gpt-4-1106-preview (a.k.a. GPT-4 Turbo).
  • ShellGPT roles (prompts) optimised for OpenAI GPT-4 models.
  • Using system roles when calling OpenAI API with messages.
  • Rendering markdown for default and describe shell command outputs.
  • New config variable CODE_THEME which sets theme for markdown (default is dracula).
  • Multiline input in REPL mode possible with """ triple quotes.
  • New --version options that prints installed ShellGPT version.
  • Fixed issue with home direcotry in Dockerfile which leading to container crash.
  • Code optimisations, minor bug fixes.

https://github-production-user-asset-6210df.s3.amazonaws.com/16740832/291779848-66392282-474e-4a84-8482-d20c53c8727d.mp4

For users which will be upgrading from previous versions it is recommended to change DEFAULT_MODEL to gpt-4-1106-preview in config file ~/.config/shell_gpt/.sgptrc since older models might not perform well with system roles. Because of significant changes in roles, unfortunately previously created custom roles and chats will not work with ShellGPT v1.0.0 and you will need to re-create them using new version.

Shoutout to all contributors: @jaycenhorton @arafatsyed @th3happybit @Navidur1 @moritz-t-w @Ismail-Ben

shell_gpt - 0.9.4

Published by TheR1D about 1 year ago

By default, ShellGPT leverages OpenAI's large language models. However, this release provides the flexibility to use locally hosted models, which can be a cost-effective alternative. To use local models, you will need to run your own API server. You can accomplish this by using LocalAI, a self-hosted, OpenAI-compatible API. Setting up LocalAI allows you to run language models on your own hardware, potentially without the need for an internet connection, depending on your usage. To set up your LocalAI, please follow this comprehensive guide. Remember that the performance of your local models may depend on the specifications of your hardware and the specific language model you choose to deploy.

  • --model parameter is now string (was enum before).
  • Added LocalAI information to README.md.
  • Created a guide on wiki page.
shell_gpt - 0.9.3

Published by TheR1D over 1 year ago

This release incorporates support for the newly announced gpt-3.5-turbo-16k model which has same capabilities as the standard gpt-3.5-turbo model but with 4 times the context.

sgpt --model gpt-3.5-turbo-16k "16k context prompt"
shell_gpt - 0.9.2

Published by TheR1D over 1 year ago

This release includes shell integrations for ZSH and Bash.

  • Added simple shell integration for ZSH.
  • Added simple shell integration for Bash.
  • New hidden option --install-integration which will update user shell profile.

Shell Integration

Shell integration allows you to use Shell-GPT in your terminal with hotkeys. It is currently available for Bash and ZSH. It will allow you to have sgpt completions in your shell history, and also edit suggested commands right away.

https://github.com/TheR1D/shell_gpt/assets/16740832/bead0dab-0dd9-436d-88b7-6abfb2c556c1

Installation

pip install --upgrade shell-gpt
sgpt --install-integration
# Restart your terminal to apply changes.

Usage

In your terminal enter natural language request, and press Ctrl+l to get shell command suggestion. It will replace your current input line (buffer) with the GPT suggested command.

List all txt files in current folder (Ctrl+l)
# -> ls *.txt

Special thanks to @chinarjoshi

shell_gpt - 0.9.1

Published by TheR1D over 1 year ago

This release includes several new features, optimizations and bug fixes:

  • New input option to describe command when executing using --shell.
  • New CLI option --describe-shell or -d to generate explanation for commands.
  • Configuration parameter to execute shell commands by default.
  • Comment lines (a line starting with #) excluded when parsing .sgptrc file.
  • Max limit of --temperature was change to 2.
  • Hiding API key from tracebacks when sgpt crashes.
  • Fixing a bug when typing exit() in REPL mode.

Describe shell commands

When executing a shell command suggestion using --shell the prompt has be changed. There are 3 new options:

sgpt -s "show all txt files in current folder"
# -> ls *.txt
# -> [E]xecute, [D]escribe, [A]bort: d
# -> List all files with .txt extension in current directory
# -> [E]xecute, [D]escribe, [A]bort: e
...

Same logic works in --repl mode:

sgpt -s --repl temp
Entering shell REPL mode, type [e] to execute commands or [d] to describe the commands, press Ctrl+C to exit.
>>> install docker
brew install docker
>>> d
Installs Docker using the Homebrew package manager.
>>> e
...

Added new option --describe-shell or -d. It allows you to generate explanation for shell commands:

sgpt -d "ls -la"
# -> List all files and directories, including hidden files, with permissions and ownership information.

Execute commands by default

New configuration parameter DEFAULT_EXECUTE_SHELL_CMD (false by default), if true will executing commands when calling sgpt --shell if no input was passed (enter). So we don't have to type "y" or "e" to execute command.

sgpt -s "say hi"
# -> echo hi
# -> [E]xecute, [D]escribe, [A]bort: (enter)
hi

Shoutout to all contributors: @chinarjoshi, @konstantin-goldman, @Daeinar, @eitamal, @cosmojg.

shell_gpt - 0.9.0

Published by TheR1D over 1 year ago

  • Custom user defined roles.
  • Option to change default roles like shell, code and default.
  • Option to force use system role messages (not recommended).
  • Improvements when passing stdin and prompt echo hello | sgpt "another hello".
  • Fixed typo in --list-chat option renamed as --list-chats

Roles

ShellGPT allows you to create custom roles, which can be utilized to generate code, shell commands, or to fulfill your specific needs. To create a new role, use the --create-role option followed by the role name. You will be prompted to provide a description for the role, along with other details. This will create a JSON file in ~/.config/shell_gpt/roles with the role name. Inside this directory, you can also edit default sgpt roles, such as shell, code, and default. Use the --list-roles option to list all available roles, and the --show-role option to display the details of a specific role. Here's an example of a custom role:

sgpt --create-role json
# Enter role description: You are JSON generator, provide only valid json as response.
# Enter expecting result, e.g. answer, code, shell command, etc.: json
sgpt --role json "random: user, password, email, address"
{
  "user": "JohnDoe",
  "password": "p@ssw0rd",
  "email": "[email protected]",
  "address": {
    "street": "123 Main St",
    "city": "Anytown",
    "state": "CA",
    "zip": "12345"
  }
}

Note that all previous chats which were created in previous version of ShellGPT will not work with this new version.

shell_gpt - 0.8.9

Published by TheR1D over 1 year ago

This release includes several backend optimizations:

  • Migrating to TOML.
  • Mypy stricted types.
  • New code linting tools.
  • Dependencies optimization.
  • sdist and bdist package optimizations.
shell_gpt - 0.8.8

Published by TheR1D over 1 year ago

  • Accept prompt from both stdin and command line argument.

This versatile feature is particularly useful when you need to pass file content or pipe output from other commands to the GPT models for summarization or analysis. For example, you can easily generate a git commit message based on a diff:

git diff | sgpt "Generate git commit message, for my changes"
# -> Commit message: Implement Model enum and get_edited_prompt()

This powerful feature simplifies the process of managing and understanding data from different sources, making it easier for you to focus on what really matters: improving your projects and applications.

shell_gpt - 0.8.7

Published by TheR1D over 1 year ago

  • Config option to change OpenAI completion color in terminal.
  • Minor config logic optimization.

You can change color of OpenAI completion by changing DEFAULT_COLOR in ~/.config/shell_gpt/.sgptrc or $DEFAULT_COLOR env, possible options: black, red, green, yellow, blue, magenta, cyan, white, bright_black, bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white.

...
DEFAULT_COLOR=magenta
shell_gpt - 0.8.6

Published by TheR1D over 1 year ago

  • Model choice option to support GPT-4.
  • Added default model to config file.

Note that GPT-4 currently in private beta, if you don't have access, you will get 404 error.

shell_gpt - 0.8.5

Published by TheR1D over 1 year ago

  • Native $SHELL command execution instead of default /bin/sh.
  • Better integration with Powershell and CMD on Windows.
  • Fixed a bug with pyreadline3 dependency for Windows systems.
  • Fixed a bug when sgpt couldn't recognize Powershell or CMD on Windows.
shell_gpt - 0.8.3

Published by TheR1D over 1 year ago

New awesome REPL mode for chat sessions. To start a chat session in REPL mode, use the --repl option followed by a unique session name. You can also use "temp" as a session name to start a temporary REPL session. Note that --chat and --repl are using same chat sessions, so you can use --chat to start a chat session and then use --repl to continue the conversation in REPL mode. REPL mode will also show history of your conversation in the beginning. REPL mode can work with --shell and --code options, which makes it very handy for interactive shell commands and code generation.

shell_gpt - 0.8.2

Published by TheR1D over 1 year ago

  • Changed default temperature value to 0.1 (more accurate responses).
  • Optimisation, command line option validations.
  • Refactoring code base.