Version1 / main.py
Prerit018's picture
Upload 26 files
6bc3db2 verified
Raw
History Blame Contribute Delete
5.57 kB
#!/usr/bin/env python3
"""
AI Teacher Bot - Complete CLI Interface
This is the main command-line interface for the AI Teacher Bot system.
"""
import os
import sys
import json
from datetime import datetime
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
from user_state import UserState
from curriculum import Curriculum, Chapter, Module
from agents.level_assess import LevelAssessmentAgent
from agents.curriculum_planner import CurriculumPlannerAgent
from agents.coordinator import CoordinatorAgent
from agents.bloom_assess import BloomsAssessmentAgent
LEVELS = ['novice', 'intermediate', 'advanced']
def print_banner():
"""Print the application banner"""
print("=" * 60)
print("🧠 AI TEACHER BOT - COMPLETE LEARNING SYSTEM")
print("=" * 60)
print("Multi-Agent Adaptive Learning Platform")
print("Features: Level Assessment, Dynamic Curriculum, Bloom's Taxonomy")
print("=" * 60)
def check_api_key():
"""Check if OpenAI API key is configured"""
api_key = os.getenv("OPENAI_API_KEY")
if not api_key or api_key == "your_openai_api_key_here":
print("❌ OpenAI API key not configured!")
print("Please set your OPENAI_API_KEY in the .env file")
print("Get your API key from: https://platform.openai.com/api-keys")
return False
return True
# Removed progress loading for now - focusing on core flow
def get_user_input():
"""Get topic and level from user"""
print("\n🎯 Let's start your learning journey!")
# Get topic
while True:
topic = input("\nWhat topic would you like to study? ").strip()
if topic:
break
print("Please enter a valid topic")
# Get level
print("\nπŸ“š What's your current experience level?")
for i, level in enumerate(LEVELS, 1):
print(f" {i}. {level.capitalize()}")
while True:
try:
level_choice = int(input("Enter the number for your level: "))
if 1 <= level_choice <= len(LEVELS):
claimed_level = LEVELS[level_choice - 1]
break
else:
print("Please enter a valid number")
except ValueError:
print("Please enter a valid number")
return topic, claimed_level
def run_level_assessment(topic, claimed_level):
"""Run level assessment for non-novice users"""
print(f"\nπŸ“ Assessing your knowledge level for {topic}...")
print("This will help us create the perfect learning path for you.")
try:
assessor = LevelAssessmentAgent()
actual_level = assessor.process(topic, claimed_level)
return actual_level
except Exception as e:
print(f"❌ Error during assessment: {e}")
print("⚠️ Defaulting to novice level")
return "novice"
def generate_curriculum(topic, level):
"""Generate curriculum for the topic and level"""
print(f"\nπŸ“š Generating personalized curriculum for {topic} at {level} level...")
try:
planner = CurriculumPlannerAgent()
curriculum = planner.process(topic, level)
print("βœ… Curriculum generated successfully!")
return curriculum
except Exception as e:
print(f"❌ Error generating curriculum: {e}")
return None
def main():
"""Main application function - Core Learning Flow"""
print_banner()
# Check API key
if not check_api_key():
return
# Get user input for new session
topic, claimed_level = get_user_input()
user = UserState(topic=topic, claimed_level=claimed_level)
print(f"\nπŸ‘€ User Profile: {user.topic} at {user.claimed_level} level")
# Level assessment
if claimed_level == 'novice':
user.set_actual_level("novice")
print("βœ… Skipping level assessment for novice users")
else:
actual_level = run_level_assessment(topic, claimed_level)
user.set_actual_level(actual_level)
print(f"βœ… Assessment complete! Your level: {actual_level}")
# Generate curriculum
curriculum = generate_curriculum(user.topic, user.actual_level)
if curriculum is None:
print("❌ Cannot proceed without curriculum")
return
# Display curriculum
print("\n" + "="*60)
print("πŸ“– YOUR PERSONALIZED CURRICULUM")
print("="*60)
curriculum.print_curriculum()
# Start teaching
print(f"\nπŸš€ Starting your learning journey at {user.actual_level} level!")
print("The AI teacher will guide you through each module step by step.")
try:
coordinator = CoordinatorAgent(user.actual_level, user)
coordinator.teach_curriculum(curriculum)
# Final summary
print("\n" + "="*60)
print("πŸŽ‰ LEARNING SESSION COMPLETE!")
print("="*60)
print("You've completed your learning journey!")
print("Great job on mastering the concepts! 🌟")
except KeyboardInterrupt:
print("\n\n⏸️ Learning session stopped by user")
print("Thanks for learning with us!")
except Exception as e:
print(f"\n❌ Error during learning session: {e}")
print("Please try again or check your configuration.")
print("\nπŸ‘‹ Thank you for using AI Teacher Bot!")
print("Keep learning and growing! 🌱")
if __name__ == "__main__":
main()