This project is a step-by-step tutorial designed for students seeking mentorship with their textbooks. Leveraging GeminiPro, it integrates a Large Language Model (LLM) and Telegram bot to provide personalized assistance. Tailored for student needs, it offers intuitive guidance, explanations, and resources, revolutionizing textbook learning.
As a fellow senior student in Computer Science and owner of study groups on Telegram, I understand the challenges students face in grasping complex material. Recognizing the need for personalized assistance, I created this tutorial. Tailored for students seeking a personal LLM bot assistant, this project offers customization options for textbooks or PowerPoint slides. It aims to revolutionize learning by providing intuitive guidance, explanations, resources, and even the ability to generate Multiple Choice Questions (MCQs) or explanations on specific topics from the materials, enhancing comprehension and reinforcing key concepts for students – all from the material set for exams.
A.Open Telegram
B.Search for BotFather
C.Start BotFather
D.Create a New Bot
E.Choose a Username
F.Copy API Token

A. Make a folder
Make folder for the project, pick any location you want for example: Desktop.
B. Open The folder in vs code:
Open VS Code and click on "File" > "Open Folder". Select the folder you created in the previous step.
C.Open Terminal in VS Code
In VS Code, you can open the terminal by clicking on "View" > "Terminal"
Note: Virtual environments are important because they allow you to isolate Python dependencies for each project, preventing conflicts and ensuring that your project runs smoothly regardless of changes to your system-wide Python setup.
A.Create a Virtual Environment
In the terminal, run the following command to create a virtual environment in your project folder:
python -m venv venv
B.Activate the Virtual Environment
To activate the virtual environment, run the following command:
- On Windows:
.\venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
You should see (venv) at the beginning of your terminal prompt, indicating that the virtual environment is active.

C.Install Packages
Now that your virtual environment is active, you can install the required packages using pip:
pip install pyTelegramBotAPI google-generativeai
D. Create 2 .py files in vc code main.py and gemini.py

In this section we will upload the Material we need such as textbook or powerpoints files and give instructions to the model to follow for example: we may train the model not to answer any pormpt or messages witout a unique word or train him to focus on certain tasks.
A. Visit Google Ai Studio https://aistudio.google.com/
B. Sign-in with your google account
C. Create new >> chat prompt


In Green area you upload your material such as textbook, In blue area you write your instructions to the model, In yellow area you must train him to make sure follow what you need note that instructions above might not follow it 100% so confirm it to the model to follow it in yellow area advice to train him here with, the more train the model the more accuracy
D.When you done training the model, click get code

E.Copy the python code

paste your code in gemini.py
F. Copy the main.py file in this project and paste it in your main.py

A. Save your work in google ai studio

B. Go to get API key

C. Create API key

A. Put your key from botfather in line 7

B. Put your key from gemini in line 16

C. Optional: type anything you want here in line 13
When you chat with your bot by pressing /start or /help you get the message you type here.

D. Copy Your System instroctutions Line in Gemini.py and replace it in main.py in line 46
E. Copy Your training prompt history in Gemini.py and paste it in main.py replace line 78 to 199
Note: Code start with this
convo = model.start_chat(history=[
it is long code based on the your training history

F. Save your work in main.py
in vs code CTRL+S
in vs code terminal type:
python main.py
Go to your bot and start chatting