An AI chatbot with Gemini API to assist in your daily usege of linux insated of RTFM π
Setuping the app on your machine
- download the repo
git clone https://github.com/AmrEL3taaL/mesba7
- Run the installer file named "mesba7"
./mesba7
-
You will be asked for the api key. to get the key go to :
- Get API key | Google AI Studio
- click on
Create API KEY
button - generate a new project if needed or select a previous google cloud project.
- Copy the api key Showen on the popup dialog
Also check the steps on the detailed images below
1. click on `Create API KEY` button
2. generate a new project if needed or select a previous google cloud project.
- A Geny will spawn on your machine granting you infinite number of wishes ;)
all you need is to call geny
and your wishes will be granted β¨
geny how to create a new directory?
mkdir directory_name
geny how to list files in a directory?
ls
geny how to copy files and directories?
cp [options] source destination
geny What is 5 + 5?
Your question is off-topic for this assistant. I can only help with questions about Linux bash commands.
Project inspiration by our beloved engineer Ramy Gomaa
step by step how to create and the code explanations
- First of all this is the python main logic code
import json
import requests
import sys
KEY="CHANGE_TO_YOUR_PRIVATE_KEY"
url = "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=" + KEY
if len(sys.argv) > 1:
text="Help with any question I ask about Linux bash commands only in very summarized answer with a short example usage and don't add any markdown styling make sure all the output you give is pair text. other wise if my question is off topic please only answer politely by refusing to answer this question. So my questions is: "+" ".join(sys.argv[1:])
else:
print("What do you want from me master ?")
sys.exit()
data = {"contents": [{"parts": [{"text": text}]}]}
response = requests.post(url, headers={"Content-Type": "application/json"}, data=json.dumps(data))
if response.status_code == 200:
print(response.json().get("candidates")[0].get("content").get("parts")[0].get("text"))
else:
print("Error:", response.status_code)
The logic behind keeping genie only in the topic of bash commands is by passing a pre prompt that engineers the output for a specific case
text="Help with any question I ask about Linux bash commands only in very summarized answer with a short example usage and don't add any markdown styling make sure all the output you give is pair text. other wise if my question is off topic please only answer politely by refusing to answer this question. So my questions is : "+" ".join(sys.argv[1:])
2. Now about how to convert the normal python code into a ready to install application for any Debian based Linux disruptions
by copying the above code don't forget to set your own API key in this step
and set it in a file named genie.py
get the path of the file
pwd ./genie.py
copy the output and add /genie.py
at the end of it
pwd genie
/home/<usrName>
thus the path is :
/home/<usrName>/genie.py
copy it and keep it for the next step.
do the following
nano ~/.bashrc
this will open a file for you in which go to last line
in the file and add the following :
alias genie='python3 /home/<usrName>/genie.py'
Now you are behind one step from the glow! update the new settings for the system to read by doing :
source ~/.bashrc
Now you can use genie just as like as you would use the installed geny from the mesba7