Shai (pronounced shy
) is a terminal-based ChatGPT-powered assistant written in Go.
Standing for ShellAI, it enables users to e employ ChatGPT to generate shell commands
based on user free-text input.
- SHAI_OPENAI_API_KEY: Set this variable to your ChatGPT API key.
- SHAI_DEBUG: Set to any value for debug mode. When in Debug Mode, raw ChatGPT responses are output for debugging purposes. Set to 0 to explicitly disable
- DUMMY_API: Set to any value to bypass querying the actual API and receive a dummy response. Useful for saving tokens during manual testing or development. Set to 0 to explicitly disable
Environment variables can be set using either the export
shell built-in or a .env
file.
To set variables via export, use:
export SHAI_OPENAI_API_KEY=your_api_key
export SHAI_DEBUG=1
export DUMMY_API=1
Alternatively, create a .env
file in the project root and add the following:
SHAI_OPENAI_API_KEY=your_api_key
SHAI_DEBUG=1
DUMMY_API=1
To use Shai, run the following command in your terminal:
shai <request string>
or for interactive query input
shai
Note: The ChatGPT API returns pure commands, so it's recommended to avoid overly ambitious queries.
Note: the setup wizard is currently a placeholder and not fully implemented.
A setup wizard is there to simplify the configuration process. To invoke the setup wizard, run:
shai setup
At the moment, there is no human-friendly error handling of the ChatGPT API non-200 responses or connectivity issues. Be aware of potential issues, and comprehensive error handling is planned for future updates.
Currently, Shai supports ChatGPT 3.5 only, but adding support for different versions as a configuration option is planned in the nearest future.
The generated commands are tailored for zsh. Support for other shells is planned.
- Clone the repository:
git clone https://github.com/vonhraban/shai.git
- Navigate to the project directory:
cd shai
- Build the project:
go build .
-
Set up the necessary environment variables or create a
.env
file. -
Run Shai:
./shai what is my current external ip address
- Optionally, symlink the binary to
/usr/local/bin
(or other folder in $PATH)
ln -s $(pwd)/shai /usr/local/bin/shai
To run unit tests, navigate to the project directory and execute:
go test ./...