shell-pilot is a simple, lightweight shell script for interacting with model services such as OpenAI, Ollama, Mistral AI, LocalAI, ZhipuAI, Anthropic, Moonshot, Novita AI, and others in the terminal. It is implemented in pure shell with no additional dependencies, with the goal of enhancing intelligent system management.
Uses:
- Directly call various online large language model APIs and local LLMs in a Linux or macOS terminal.
- Build a local LLM repository based on Ollama (supports deepseek, llama3.x, gemma2) and work with the Ollama API.
- Use models such as OpenAI (ChatGPT), Mistral AI, LocalAI, ZhipuAI, Anthropic, Moonshot, Novita AI, and others through official APIs.
Main capabilities:
- View history and session persistence.
- Chat context: the model can remember previous questions and answers.
- Support passing input prompts through pipes/redirection (|, <), script arguments, or normal chat mode (requires bash 4.0+).
- List all available models.
- Set OpenAI request parameters.
- Generate commands and run them in the terminal, with code chat mode support for easy interaction.
- Easily set configuration in command arguments, or use vi mode to edit configuration (option e).
- Enhance system interaction and efficiency through features oriented toward basic system management.
- Modular plugin design for easy extension: each plugin introduces new functionality, making the tool more powerful and adaptable to different needs.
- Conveniently check system package versions (currently supports macOS/RHEL/CentOS/Fedora).
- Conveniently add/list/remove aliases from the command line.
Usage:
- Depends on curl to make API requests and jq to parse JSON responses.
- Requires an OpenAI API key (available by registering with OpenAI).
- Optionally install glow for markdown rendering of responses.
- Ollama environment can be configured (including manual installation instructions, usage instructions, and model library) or LocalAI environment (including manual instructions and GitHub repository).
- During installation, run the command in the terminal and provide the OpenAI API key when prompted; ifit is not set during installation, the local Ollama server IP needs to be set in the configuration file spilot_common.sh.
- Other parameters can be set in spilot_common.sh before use.
- Manual installation: download the shell-pilot project files; you can reset the script path (default is /usr/local/bin/) or the output storage path (default is ~/spilot_files_dir); set permissions; move the files to the directory; add settings in the configuration file; use the s-pilot command to run the script anywhere; pipe mode can also be used.
- Help commands: h, -h, --help.
- Chat mode can take an initial prompt; the model provider can be changed by modifying spilot_common.sh.
- history: view chat history; models: list available models for OpenAI API/Ollama; model: plus model id (no spaces) to view information about a specific model; cmd: plus a feature description to get and run a command; it will ask before execution, and if the command modifies the file system or downloads external files it will show a warning, and by default the execution flag is disabled when danger is detected.
- Supports session persistence, one-shot command mode, and interactive session mode.
- For non-gpt-3.5-turbo and gpt-4 models whose OpenAI API does not support chat context, you can use the script's built-in chat context mode, enabled via c, -c, or --chat-context (for example, s-pilot c true); the initial chat prompt can be customized (ip, -ip, --init-prompt, or --init-prompt-from-file).
- Default models: OpenAI is gpt-3.5-turbo, Ollama is llama2, MistralAI is mistral-small.
- Using other models: for OpenAI you can set gpt-4 (for example, s-pilot --model gpt-4); for Ollama you can first pull (for example, ollama pull mistral), then set it with s-pilot e; for MistralAI you can use s-pilot lm to view and set it with s-pilot e.
- Set request parameters: for example, s-pilot t 0.9; the parameters will be saved to spilot_common.sh. Available parameters include temperature (t, -t, --temperature), model (m, -m, --model), max tokens (mt, -mt, --max-tokens), prompt (p, -p, --prompt), read prompt from file (pf, -pf, --prompt-from-file).
- Plugin feature examples: pv checks system package versions (supports MacOS/RHEL/CentOS/Fedora); sa manages system aliases.
Use cases:
- Quickly interact with multiple large language models in the terminal.
- Intelligent system management, such as querying package versions, managing aliases, and generating and executing commands.
- Chat, question answering, and code interaction with local or online LLMs.
Limitations:
- The project is still in the testing stage and is not yet production-ready. Do not use it in critical/production systems, and do not use it to analyze customer data.
- Depends on curl and jq.
- The chat context feature requires enabling the script's built-in mode for some models other than gpt-3.5-turbo and gpt-4.
- System package version checking currently supports MacOS/RHEL/CentOS/Fedora.