Tired of switching between your terminal and the browser for chat GPT
Imagine having the power of chat GPT right at your fingertips in your Linux terminal
That is where the Cell GPT comes in. Cell GPT is a fantastic tool that allows you to interact with the open AI GPT models directly
from your Linux command line. It's like having a personal AI assistant right there in your Linux terminal
In this video tutorial, I will show you how to install and use Cell GPT on Linux terminal
Before starting the installation, make sure following things are in place. We need a Linux system, can be a Debian or RHL based distribution, local user with sudo
rights and internet connectivity. Let's deep dive into the actual steps. For the demonstration, I am using Ubuntu 24.04 LTS server
And for the interest of time, I have already prepared a set of steps that I will be using
in this video tutorial. I will share these steps in the description of the video for your reference
The first step is to install python3 python3-pip and python3-vnv. As we are using Debian, so we will be using apt command to install these packages
Now move to the terminal. Run sudo apt update. This command will update your repository's index
Now run apt sudo apt install python3 python3-pip and python3-vnv
So depending upon your internet speed, it may take a minute or two
In case you are using RHL based distribution, so you have to use yum or dnf command in place
of apt and the rest of the command will remain the same
So for RHL based system, you need to run these commands. sudo space yum update hyphen y and then sudo space yum install and these python packages. Ok
Next step is to create a virtual environment. So it is highly recommended to have a virtual environment for your python projects. Ok
Let us create a folder first using mkdir command. Now go to this folder
Now create a virtual environment. For that, run this command python space hyphen nvnv and sgpt
Sgpt is your virtual environment name and vnv is our module. So we are using vnv module to create this virtual environment with the name sgpt
Ok this command. Ok. Now we need to activate this virtual environment
For that, run the command source space sgpt slash bin slash activate
So this will activate my virtual environment. Now install the sgpt module here
For that, run pip space install space shell hyphen gpt
So this shell gpt will be installed only in this virtual environment
So hit enter. Ok. The output confirms that shell gpt has been installed successfully in our virtual environment
Now move to the next step. Next we need to get the openAI API keys
For that, we need to visit this URL platform.openai.com. Create an account if you don't have one
Once you are logged in, you will get the screen something like this
Click on the API keys. And then click on create new secret key
Give the name of your API key, let's say Linux API key and select the project
So I am going with the default project. Click on create secret key
Copy this key and store it somewhere safe in your system. Once you click on done, you can't get or you can't retrieve these keys
So I want to save it here. Click on done. Define your open API key using a variable openAI underscore API underscore key
Like this. You need to replace your openAI key here. So in my case, this would be the command
So we are defining the variable and exporting it using export command
Hit enter. In order to define this variable permanently so that every time whenever a user logged
in on this terminal, so this variable should be exported automatically. So in that case, we need to define this variable under the base RC file
Hit enter. Ok. Now verify the self-GPT version
For that, run the command sgpt. Ok
We are running SLGPT version 1.4.3. Now move to the most interesting part
How we can query and start interacting with the chat GPT using SLGPT command line
For that, let's say I want to get a procedure how to create a VNet peering using az command
for Azure cloud. For that type sgpt and in double quotes specify your query
Hit enter. Great, we have the steps. The first step is to log in, perform an az login and then use az network vnet peering
command to create the vnet peering. Great. We want to see what are the different options I can use in this sgpt command
For that you can run sgpt hyphen hyphen help. Ok
So there are other options that we can use like cell code
Let's say I want to generate a code in the form of a cell script
I want a cell script that will take the backup of all the important configuration files on Linux
If you copy this command
Let's say all important network configuration files in Linux. So hyphen hyphen code will write the code and will display that code on our terminal. Great
You can see we have this cell script that will take the backup of network configuration
files in a Linux system. Let's say I want to generate the code as well as I want to execute it on the fly
In that case we can use hyphen hyphen shell option. Let's try this example
This will create and execute a cell script which will count the files and directories
in current slash home slash linux tacky folder. So hit enter
Now it is prompting you whether you want to execute, describe or abort this code
Let's say I want to execute type caps E. Hit enter. And there you have
So we have the files and the directories that is currently there in the slash home slash
in stacky folder. So to deactivate or come out of this virtual environment type deactivate command
And hit enter. Okay. As you can see, we came out from the virtual environment
Let's say I want to connect it again and I want to use the sgpt commands
For that you need to run. First you need to make sure you are into the sgpt folder that you have created initially
and then run source folder name and then bin activate. Okay
We are into the virtual environment. Now you can again start using sgpt
That's all from this video tutorial. I hope you have found it useful and informative
Please like the video and subscribe our channel for more tech tutorials like this. Bye
Have a nice day