This repository contains a simple yet powerful Python application that leverages the Google Generative AI API to create an interactive chatbot. The chatbot is specifically designed to act as an expert in teaching science to kids, making complex scientific concepts accessible and engaging through conversation, analogies, humor, and real-world examples. It's a great starting point for anyone looking to build conversational AI agents with a specific persona and educational focus.
- Interactive Science Tutor Bot: Engages users in conversations about science, explaining concepts in an easy-to-understand manner suitable for children.
- Personalized Learning Experience: Uses analogies, relatable examples, humor, and asks questions to tailor the educational experience.
- Real-World Connections: Suggests ways scientific concepts relate to the real world, encouraging observation and experimentation.
- Google Generative AI Integration: Utilizes the
gemini-2.5-promodel for powerful natural language understanding and generation. - Configurable Generation Settings: Allows customization of AI response generation parameters like temperature, top-p, top-k, and max output tokens.
- Safety Settings: Implements configurable safety settings to manage harmful content categories.
- Environment Variable Support: Uses
.envfile for securely managing API keys.
- Languages: Python 🐍
- Frameworks/Libraries:
google-generativeai: For interacting with the Gemini API.python-dotenv: For loading environment variables from a.envfile.
- AI Model: Gemini 2.5 Pro
To set up and run this project locally, follow these steps:
-
Clone the Repository:
git clone https://github.com/SG17THEProgrammer/GenAI.git cd GenAI -
Install Dependencies: The project relies on a few Python packages. It's recommended to use a virtual environment.
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate` pip install google-generativeai python-dotenv
-
Set Up API Key:
- Create a
.envfile in the root directory of the project (GenAI/.env). - Add your Google Generative AI API key to this file in the following format:
GEMINI_API_KEY='YOUR_API_KEY' - Obtain an API key from the Google AI Studio: https://makersuite.google.com/app/apikey
- Create a
This project provides a command-line interface (CLI) application that allows you to interact with the AI chatbot.
-
Run the Application: Navigate to the
genAICourseMicrosoft/Practicedirectory and run theapp.pyscript.cd genAICourseMicrosoft/Practice python app.py -
Interact with the Bot: The application will start, and you'll see the initial greeting from the bot. You can then type your questions or prompts related to science.
Bot: Hello, how can I help you? You (Enter `exit` to exit the bot else write your prompt): What is photosynthesis?The bot will respond with an explanation tailored for children.
-
Exiting the Chat: Type
exitand press Enter to end the conversation.
Real-World Use Case: This application serves as a fantastic educational tool for parents and educators looking to make learning science fun and accessible for children. It can be used for homework help, sparking curiosity about scientific topics, or simply engaging in interactive learning sessions.
To get started with the interactive science tutor:
- Ensure you have completed the Installation steps.
- Execute the
app.pyscript from thegenAICourseMicrosoft/Practicedirectory usingpython app.py. - Engage in a conversation with the bot by typing your science-related queries. The bot is programmed to be a knowledgeable and engaging science educator for kids.
- For example, you can ask questions like:
- "Why is the sky blue?"
- "What happens when you mix baking soda and vinegar?"
- "Tell me about dinosaurs."
The bot will provide age-appropriate explanations, use analogies, and encourage further exploration.
GenAI/
├── .env
├── Gen_AI_Global_Logic_Numpy.ipynb
├── Gen_AI_Global_Logic_NumpyL1_L3.ipynb
├── Global_Logic_L3_L5.ipynb
├── Pandas.ipynb
├── Practice.ipynb
├── ipl dataset.csv
├── matches.csv
└── genAICourseMicrosoft/
├── ChatApplication/lec7.txt
├── Creating_Adv_Prompts/lec5.txt
├── Explore_Compare_LLMS/lec2.txt
├── ImageApps/lec9.txt
├── Intro_To_GenAI/lec1.txt
├── Prompt_Engg_Fundamentals/lec4.txt
├── SearchApps/lec8.txt
├── Using_GENAI_Responsibly/lec3.txt
└── Practice/
└── app.py
genAICourseMicrosoft/Practice/app.py: The main Python script for the interactive chatbot..env: Stores sensitive API keys and environment configurations..ipynbfiles: Jupyter notebooks, likely containing course material or examples related to AI, Numpy, and Pandas..txtfiles: Text files withingenAICourseMicrosoftsubdirectories, probably containing lecture notes or learning materials for different AI topics..csvfiles: Dataset files (ipl dataset.csv, matches.csv) that might be used in conjunction with notebooks for data analysis examples.