Skip to main content

Chat with LLM in your terminal, be it shell generator, story teller, linux-terminal, etc.

Project description

ShellGPT

Chat with LLM in your terminal, be it shell generator, story teller, linux-terminal, etc.

Install

pip install -U shgpt

Or install latest version

pip install --force-reinstall -U git+https://github.com/jiacai2050/shellgpt.git

This will install two commands: sg and shellgpt, which are identical.

After install, use sg --init to create required directories(mainly ~/.shellgpt).

Usage

ShellGPT has three modes to use:

  • Direct mode, sg [question] or pipeline like echo question | sg.
  • REPL mode, sg -r, chat with LLM.
  • TUI mode, sg -t, tailored for infer shell command.

Model

By default, shellgpt uses Ollama as its language model backend, requiring installation prior to usage.

Alternatively, one can set up shellgpt to utilize OpenAI compatible API endpoints:

export SHELLGPT_API_URL=https://api.openai.com
export SHELLGPT_API_KEY=<token>
export SHELLGPT_MODEL='gpt-3.5-turbo'

# or Cloudflare Worker AI
export SHELLGPT_API_URL=https://api.cloudflare.com/client/v4/accounts/<account-id>/ai
export SHELLGPT_API_KEY=<token>
export SHELLGPT_MODEL='@cf/meta/llama-3-8b-instruct'

See conf.py for more configs.

TUI

There are 3 key bindings to use in TUI:

  • ctrl+j, Infer answer
  • ctrl+r, Run command
  • ctrl+y, Yank command

TUI screenshot

System contents

There are some built-in system contents in shellgpt:

  • default, used for ask general questions
  • typo, used for correct article typos.
  • slug, used for generate URL slug.
  • code, used for ask programming questions
  • shell, used for infer shell command
  • commit, used for generate git commit message, like git diff | sg -c commit

Users can define their own content in ~/.shellgpt/contents.json, it a JSON map with

  • key being content name and
  • value being content body

Or you can just copy contents.json to play with, it's generated from Awesome ChatGPT Prompts.

$ sg -c linux-terminal pwd
/home/user

$ sg -c javascript-console 0.1 + 0.2
0.3

Users can share their customized contents in discuss section.

License

GPL-3.0

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

shgpt-0.5.2.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

shgpt-0.5.2-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file shgpt-0.5.2.tar.gz.

File metadata

  • Download URL: shgpt-0.5.2.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for shgpt-0.5.2.tar.gz
Algorithm Hash digest
SHA256 b1509b3141bd11bbc4703aecc41fccf9c7b8b4bc09da4d182010b0ed10b206c9
MD5 c93dc4b7e132eef0c78d2dd2a2a476d5
BLAKE2b-256 702bd6bb26caa9f311d7f2674c58d8518a99088bcf5c742b60304dbb8c49f400

See more details on using hashes here.

File details

Details for the file shgpt-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: shgpt-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for shgpt-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 52272acb217fe93b9e6c7239b71c10d41d769f3f14b32d196d4542f237f568ed
MD5 9651351baf806839b917a5eea51f4110
BLAKE2b-256 24f607b93ec80192a78355ddeae054b343f2484ef86808be4ba838bd69c82b5f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page