Here's how I managed to use ChatGPT AI chat bot in my own terminal.
For running it on Windows or Android (Termux App) follow the section Manual Installation down on this post.
- Install chatGPT using Linux-Auto-Customizer (easiest way):
GNU/Linux:
sudo apt-get install -y git python3 build-essential portaudio19-dev
git clone https://github.com/AleixMT/Linux-Auto-Customizer
cd Linux-Auto-Customizer
git checkout chatGPT_feature
bash src/core/install.sh -v -o chatGPT
Log into openAI web page and get your API key.
Change 'your_API_key_value' to the one you got from openai webpage before running the next command:
echo "OPENAI_API_KEY=your_API_key_value" > ~/.customizer/bin/chatGPT/Content/Python/chatBot/.env
bash
That's it, now just type chatGPT in the console and magic happens.
Use exit or quit words to end the conversation.
You can use talkGPT (but not yet in Android) to talk to the console and the AI will respond using a custom voice too.
talkGPT
Also you can generate code using the function codeGPT to generate code when commentaries are passed to it.
Example:
codeGPT "# Python3 # A code to store a list of dictionaries of fruits and vegetables"
Manual Installation
If you want to recreate the running of the script manually, follow the steps below:
chatGPT
- Install Python3 and Git
GNU/Linux:
sudo apt-get install -y python3 git
Termux (Android):
pkg install -y root-repo
pkg update -y
pkg upgrade -y
apt install -y git build-essential python3
- Install Python dependencies
GNU/Linux:
pip3 install openai python-dotenv transformers colorama
Windows:
pip install openai python-dotenv transformers colorama
Termux (Android):
MATHLIB="m" pip3 install numpy openai
pip3 install wheel setuptools python-dotenv colorama
Clone git repository
git clone https://github.com/Axlfc/UE5-python
Navigate to Content/Python/chatBot repository directory
Log into openAI web page and get your API key.
Edit .env file from the repository folder and paste your API Key to set the variable OPENAI_API_KEY
Run conversate.py to begin to conversate with the AI locally on your terminal.
GNU/Linux & Termux (Android):
python3 conversate.py
Windows:
python conversate.py
If you want to run a simple command chat
to run chatGPT in Windows Terminal, you can edit the C:\Users\Your_Username\Documents\WindowsPowershell\Microsoft.PowerShell_profile.ps1 file and add to it the following lines:
function chat_function {
python C:\Users\Your_Username\Desktop\UE5-python\Content\Python\chatBot\conversate.py
}
Set-Alias chat chat_function
If you also want that chat
alias in GNU/Linux or Android, you can edit ~/.bash_aliases
file and add:
chat() {
python3 "~/UE5-python/Content/Python/chatBot/conversate.py"
}
Now when you type chat
in your Terminal it will start chatGPT.
talkGPT
If you want the AI to talk to you using a concrete voice, you should try running talk.py script which is used to make the AI process an audio file of their response, for the moment voice chat works only on Windows or GNU/Linux:
-Install portaudio
GNU/Linux:
sudo apt-get install -y build-essential portaudio19-dev
- Install the required Python dependencies and it should work:
GNU/Linux:
pip3 install git+https://github.com/openai/whisper.git jiwer gitpython gdown pathlib setuptools pyaudio soundfile pathlib numpy librosa SpeechRecognition langdetect googletrans==4.0.0-rc1
Windows:
pip install git+https://github.com/openai/whisper.git jiwer gitpython gdown pathlib setuptools pyaudio soundfile pathlib numpy librosa SpeechRecognition langdetect googletrans==4.0.0-rc1
- Run talk.py to begin to talk with the AI locally on your terminal, the voice will process and then played.
GNU/Linux:
python3 talk.py
Windows:
python talk.py
Voice processing in talk.py script isn't able to mantain a conversation (almost) real time with the ChatGPT AI due to long audio processing time, but it is definitely possible.
codeGPT
If you only want the AI to generate code for you, use the script code.py and pass some commented code to it and it will reply creating code for you!
Did this article helped you? Share it, comment or give a like if it did! 😄
Top comments (0)