A command line interface to ChatGPT and prepared prompts.
STATUS: Extremely unstable
Reference Documentation:
Inside the prompts directory you will find prepared prompts you can use to help you focus your chat sessions.
If you create a great prompt, please create a pull request and I'll add it in.
You can use the ai
command line tool located in this repository to interact with ChatGPT from the terminal.
Features:
- Uses an OPENAI_API_KEY, which is far cheaper than a subscription
- Prepared prompts. eg:
ai python "read a csv file"
- Start interactive sessions or one-time requests
- Asynchronous or synchronous interface
The ai command is simply a Python script. To install the ai command, follow these steps.
If you don't have Python installed you will need to install Python v3. The script has been tested on Python v3.10.
https://www.python.org/downloads/
Once installed, test it by opening a terminal or command prompt and typing:
python --version
pip --version
Python supports many different modules. This command line tool uses the following installable modules:
To install these modules, use the following command in the terminal:
python -m pip install argparse openai pick prompt_toolkit rich fpdf markdown pyperclip
You'll also need to make sure you have 'tk' installed:
sudo pacman -S tk
If you would prefer, there is a pyproject.toml file for a Poetry installation.
You will need git installed to carry out this step.
For Linux:
bin_path="${HOME}/bin"
mkdir -p "${bin_path}"
cd "${bin_path}"
git clone https://github.com/grantcarthew/python-ai ai
To be able to run the command without changing into the cloned directory, you will need to edit your PATH
environment variable.
For Linux:
echo 'export PATH="${PATH}:${HOME}/bin/ai"' >> "${HOME}/.bashrc"
To pickup the new PATH environment variable, restart your terminal.
At this point, you should have access to the ai
command.
Try this:
ai -i "Hi"
The above example is calling the ai
command, enabling "interactive mode" with -i
, and then saying "Hi" to ChatGPT.