Skip to content

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.

Notifications You must be signed in to change notification settings

SenseiNasser/Tutorial-Leveraging-LLM-and-Telegram-Bot-Integration-in-GeminiPro-for-Student-Mentorship

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

Tutorial-Leveraging-LLM-and-Telegram-Bot-Integration-in-GeminiPro-for-Student-Mentorship

Description

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.

Brief

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.

Tools used in this project

My Skills

Instructions

Step 1: Creating telegram bot API token

A.Open Telegram

B.Search for BotFather

C.Start BotFather

D.Create a New Bot

E.Choose a Username

F.Copy API Token

Screenshot 2024-04-25 211618

Step 2: Setting Environment in VS Code and Use Terminal

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"

Step 3: Create Virtual Environment and install requirement packages.

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.

Screenshot 2024-04-25 234752

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

Screenshot 2024-04-26 005201

Step 3: Sign-in Google Ai Studio & train your model

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

Screenshot 2024-04-26 001843 V

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

Screenshot 2024-04-26 005055

E.Copy the python code

Screenshot 2024-04-26 005117

paste your code in gemini.py

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

Screenshot 2024-04-26 011817

Step 4: Create API Gemini key

A. Save your work in google ai studio

Screenshot 2024-04-26 012224

B. Go to get API key

Screenshot 2024-04-25 225920

C. Create API key

Screenshot 2024-04-25 225944

Step 5: Edit the main.py before run it

A. Put your key from botfather in line 7

Screenshot 2024-04-26 012619

B. Put your key from gemini in line 16

Screenshot 2024-04-26 012911

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.

Screenshot 2024-04-26 013123

D. Copy Your System instroctutions Line in Gemini.py and replace it in main.py in line 46 Screenshot 2024-04-26 013600

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

Screenshot 2024-04-26 014459

F. Save your work in main.py

in vs code CTRL+S

Step 6: Run the bot

in vs code terminal type: python main.py

Go to your bot and start chatting

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages