An intelligent study companion leveraging AI/NLP technologies and LangChain to provide personalized learning support, interactive quizzes, and detailed explanations for students across any subject.
- Conversational Learning: Natural chat interface for studying any subject
- Conversation Memory: Remembers context across the entire study session
- Interactive Quizzes: Generate custom quiz questions based on your study topics
- Detailed Explanations: Get simple, clear explanations with real-world examples
- Teaching Persona: Patient, encouraging AI tutor designed for effective learning
- Session Summaries: Review your study session and conversation history
This AI Study Assistant demonstrates practical application of:
- LangChain Framework for building conversational AI
- Memory Management for context-aware conversations
- Chain Orchestration with specialized chains for different tasks
- Prompt Engineering for educational effectiveness
- Python 3.7+
- OpenAI GPT-3.5-turbo API - Conversational AI model
- LangChain - Framework for building AI applications
- LangChain Memory - Conversation history management
- Python-dotenv - Environment variable management
Before you begin, ensure you have:
- Python 3.7 or higher installed
- An OpenAI API key (Get one here)
- pip package manager
- Basic command line knowledge
-
Clone the repository
git clone https://github.com/Rtollinchi/ai-study-assistant.git cd ai-study-assistant -
Create a virtual environment (recommended)
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
Create a
.envfile in the root directory:touch .env
Add your OpenAI API key:
OPENAI_API_KEY=your_api_key_here
-
Run the application
python app.py
-
Start studying
The assistant will greet you and wait for your input.
-
Natural Conversation: Just chat about what you're studying
You: Can you help me understand photosynthesis? -
Quiz Mode: Test your understanding
You: quiz me -
Detailed Explanations: Get in-depth explanations
You: explain photosynthesis -
Exit: End your study session
You: exit
🎓 Welcome to Your AI Study Assistant!
========================================
I can help you study any subject!
Commands:
- Just chat naturally about what you're studying
- Type 'quiz me' to get quiz questions
- Type 'explain [topic]' for detailed explanations
- Type 'exit' to quit
============================================================
✅ Study Assistant initialized with memory!
🧐 You: I'm studying the water cycle for my science test
🤖 Study Assistant: Great! The water cycle is a fundamental concept in Earth science.
Let me help you understand it better. The water cycle describes how water moves
between Earth's surface and the atmosphere through evaporation, condensation,
and precipitation...
🧐 You: quiz me
🤖 Study Assistant:
Q1: What are the three main processes in the water cycle?
Q2: What happens to water during evaporation?
Q3: Where does condensation occur in the water cycle?
🧐 You: exit
👋 Good luck with your studies!
📊 Session Summary:
Conversation history:
[Your study session summary...]
- ConversationChain: Main conversation handler with memory
- Memory System: Tracks conversation history for context
- Specialized Chains:
- Quiz Chain: Generates relevant quiz questions
- Explanation Chain: Provides detailed topic explanations
- Command Processor: Handles special commands and routing
- Temperature Setting (0.7): Balanced between creativity and accuracy
- Token Limit (300): Optimized for concise, focused responses
- Context Preservation: Maintains full conversation history
- Error Handling: Graceful error management with user feedback
ai-study-assistant/
├── app.py # Main application file
├── requirements.txt # Python dependencies
├── .env # Environment variables (not in repo)
├── .gitignore # Git ignore file
└── README.md # This file
Important: Never commit your .env file or expose your OpenAI API key. The .gitignore file should include:
.env
__pycache__/
*.pyc
.venv/
venv/
Create a requirements.txt file with:
langchain
langchain-openai
openai
python-dotenv
Potential improvements for this project:
- Add Gradio/Streamlit web interface
- Implement topic-specific study plans
- Add flashcard generation
- Include progress tracking and analytics
- Support multiple languages
- Add voice input/output capabilities
- Integrate with note-taking apps
Rubin Tollinchi
- GitHub: @Rtollinchi
- LinkedIn: LinkedIn
- Portfolio: Website
- OpenAI for providing the GPT-3.5-turbo API
- LangChain team for the excellent AI framework
- The education technology community
If you're interested in building similar projects:
If you have any questions or run into issues, please open an issue in the GitHub repository.
⭐ If you found this project helpful for learning, please consider giving it a star!