AmrEL3taaL / mesba7

A chatbot in the terminal supports the new ubuntu -Debian based- Linux users

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mesba7 πŸ’‘

GitHub Repo stars Forks
An AI chatbot with Gemini API to assist in your daily usege of linux insated of RTFM πŸ˜‰

Installation

Automated setup

Setuping the app on your machine

pre steps

  1. download the repo
git clone https://github.com/AmrEL3taaL/mesba7
  1. Run the installer file named "mesba7"
./mesba7

Get your own API key

  1. You will be asked for the api key. to get the key go to :

    1. Get API key | Google AI Studio
    2. click on Create API KEY button
    3. generate a new project if needed or select a previous google cloud project.
    4. Copy the api key Showen on the popup dialog

    Also check the steps on the detailed images below



detailed images

1. click on `Create API KEY` button

1

2. generate a new project if needed or select a previous google cloud project.

2

  1. A Geny will spawn on your machine granting you infinite number of wishes ;)

How to use

all you need is to call geny and your wishes will be granted ✨

examples:

geny how to create a new directory?
output
mkdir directory_name
geny how to list files in a directory?
output
ls
geny how to copy files and directories?
output
cp [options] source destination
geny What is 5 + 5?
output
Your question is off-topic for this assistant. I can only help with questions about Linux bash commands.

Genie 🧞 and the project.

Project inspiration by our beloved engineer Ramy Gomaa

Manual setup

step by step how to create and the code explanations

  1. 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

that's it πŸ‘€

About

A chatbot in the terminal supports the new ubuntu -Debian based- Linux users


Languages

Language:Shell 100.0%