Spaces:
Sleeping
Sleeping
File size: 5,569 Bytes
6bc3db2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | #!/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()
|