Installation of SGPT in our Linux system.
SGPT is known as ShellGPT which is a powerful toll that utilizes OpenAI’s GPT (Generative pre-trained Transformer) that provides an interactive shell experience to the User. It can be used to execute commands, get code completions, give answers to the questions we ask.
In this article we are going to Install SGPT in our linux system (Ubuntu). One can follow easy steps of installation and configuration.
Step 1: Update and Upgrade the System
sudo apt update
sudo apt upgrade -y
These are used in Ubuntu and other Debian-based systems to update and upgrade the installed software packages.
Step 2: Install Python 3 and PIP
If Python 3 is not already installed, run the following command:
sudo apt install python3 -y
Install PIP (Python package manager) using this command.
sudo apt install python3-pip -y
Step 3: Install SGPT via PIP
To install SGPT, execute the following command:
pip install shell-gpt --user
Step 4: Adding ShellGPT in Our Linux path
Edit our shell configuration file (e.g., ~/.bashrc), use text editor like nano for adding this line in the end of the file:
nano ~/.bashrc
#Add this line in the endexport
PATH=$PATH:~/.local/bin
Refresh the shell configuration or open a new terminal to get the updated terminal.
#use this command to refresh the terminal
source ~/.bashrc
Step 5: Creating an OpenAI API key.
1) Visit the OpenAI website:
Go to the OpenAI website at https://www.openai.com/.
Sign in or create an account: If you already have an account, sign in using your credentials. Otherwise, click on the “Sign Up” button to create a new account.
On the top right corner CLICK on profile. You will see `view API keys` Click on it.
2) Create a new API key:
After selecting view API keys, Click on Create new secrete key
3) Enter your key name:
Enter your desired key name here and click on Create secret key.
4) KEY Generated:
Copy your Key from the prompt.
Note: Copy the Prompted key and save it somewhere. Do not share your key with anyone, for security reasons.
Step 6: Create a file named .sgptrc inside the ~/.config/shell_gpt directory
nano ~/.config/shell_gpt/.sgptrc
Add the following line to the file.
OPENAI_API_KEY=<YOUR_API_KEY>
replacing <YOUR_API_KEY> with your actual OpenAI API key
Step 7: Use of SGPT.
To test if SGPT is working correctly, open a new terminal and run the command:
sgpt --shell
Now you can ask it questions related to shell.
For Example:
sgpt --shell "echo hello"
type option(e)
sgpt --shell "ls"
type option(e)
Certainly, it has few Options.
#use this to see all the available options
sgpt --help
Create
How to Use chatgpt on Linux
OpenAI has developed an AI-powered chatbot named `ChatGPT`, which is used by users to have their answers to questions and queries. One can access ChatGPT on searchingness easily. But some users want to access this chatbot on their Linux System. It can be accessed as a Desktop application on Ubuntu or can be accessed by the Linux terminal.
In this article, we are going to discuss two ways to get ChatGPT on our terminal in Linux System. They are Terminalgpt and Shell-GPT (sgpt).