Table of Contents
- Python Package for ChatGPT
- Getting ChatGPT API Key
- Save your ChatGPT API key like an SSH key in Git Bash in 2 Steps!
- Alias ChatGPT
- Update Software Package
Python Package for ChatGPT
There is a Python package that brings #ChatGPT to the command line!
Check it out:
Getting ChatGPT API Key
To use this tool you will need a ChatGPT API Key.
Save your ChatGPT API key like an SSH key in Git Bash in 2 Steps!
Rather than manually key in the API key, we can save it like an SSH key as follows:
Step 1
Pass the env var inside your .bashrc file.
To pass the env var, set an environment variable in Git Bash, you can use the export
command. For example, to set the environment variable VARNAME
to the value varvalue
.
In this case, we use: CHATGPTKEY
as the VARNAME
and ChatGPT api key as the varvalue
.
Here's the example:
# Source chatgptkey for [ai-chat-tool](https://pypi.org/project/ai-chat-tool/)
export CHATGPTKEY="<YOUR_CHATGPT_API_KEY>"
Save the bash.bashrc file, exit Git Bash and rerun it.
Step 2
To validate the success of Step 1, run:
echo $CHATGPTKEY
Your ChatGPT API key should be shown in the Terminal.
Voilà , Bob's your uncle!
You can simply run the ai-chat-tool in the Terminal literally as follows:
python -m ai-chat-tool --api-key=$CHATGPTKEY
Alias ChatGPT
Create alias for ease of use. What is your favourite alias for ChatGPT in Python? Comment down below!
For more info on creating aliases, please refer to my post here.
No more manual API input, ease of use, and happy days!
Cheerios!
Update AI ChatBot Tool
Here's a short instruction on how to update the "ai-chat-tool" Python package using pip:
- Open your terminal or command prompt.
- Type the following command:
pip install --upgrade ai-chat-tool
- Press Enter to execute the command.
- If the package is already installed on your system, pip will check if there is a newer version available and upgrade it if necessary.
- Wait for the upgrade process to complete. Depending on your internet connection and the size of the package, this may take a few seconds to several minutes.
- Once the upgrade is complete, you should see a message indicating the version of the package that was installed or upgraded.
That's it! Your ai-chat-tool package should now be updated to the latest version. You can confirm this by running the command "pip show ai-chat-tool" to see the current version installed on your system.
Top comments (7)
Thanks for this one is te easiest use of
chatgpt
!I added to my .zshrc
for short use
version 0.0.9 already released and more features coming soon already in dev's roadmap. I like it when someone uses useful shortcut with zero nonsense & just for the sake of show off, cheers!
Nice article @pizofreude!
Thanks for reading ma-man!
Thanks @pizofreude for writing this blog! I really appreciate the support. I just pushed version 0.0.11 which added the ability to write ChatGPT output to a file at a specific line.
My pleasure, I'm thrilled ever since the inception release. 🙂 You're killin' it man, congrats and thanks for your awesome contribution!
Tested with Python3.11, not sure whether it will work with prior release of Python2.