#!/usr/bin/env python3 """ ๐ŸŽฏ EKALAVYA - Interactive Teaching Demo ๐ŸŽ“ Learn English with AI โ€ข ๐Ÿ’ Friendly Conversations โ€ข ๐Ÿง  Memory-Powered """ from model.teaching import TeachingMode from model.safety import SafetyRules def print_header(): """๐ŸŽจ Print beautiful header""" print(""" โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•— โ•‘ โ•‘ โ•‘ ๐ŸŽฏ EKALAVYA - AI Teaching Assistant โ•‘ โ•‘ โ•‘ โ•‘ ๐ŸŽ“ Interactive Teaching Mode โ•‘ โ•‘ โ•‘ โ•‘ ๐Ÿ’ Choose Your Style: โ•‘ โ•‘ ๐Ÿ‘ซ Friend โ€ข ๐Ÿ‘จโ€๐Ÿซ Teacher โ€ข ๐Ÿ’• Lover โ€ข ๐ŸŽ“ Mentor โ•‘ โ•‘ โ•‘ โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• """) def get_user_choice(prompt, options): """๐ŸŽฏ Get user choice with emojis""" print(f"\n{prompt}") for i, (key, value) in enumerate(options.items(), 1): print(f" {i}. {value}") while True: try: choice = int(input("\n๐Ÿ‘‰ Enter your choice (1-{}): ".format(len(options)))) if 1 <= choice <= len(options): return list(options.keys())[choice - 1] print("โŒ Invalid choice, try again!") except ValueError: print("โŒ Please enter a number!") def demo_teaching_mode(): """๐ŸŽ“ Run interactive teaching demo""" print_header() # ๐ŸŽฏ Choose conversation style styles = { "friend": "๐Ÿ‘ซ Friend - Casual and supportive", "teacher": "๐Ÿ‘จโ€๐Ÿซ Teacher - Formal and educational", "lover": "๐Ÿ’• Lover - Caring and affectionate", "mentor": "๐ŸŽ“ Mentor - Wise and guiding" } print("\n๐Ÿ’ Choose your conversation style:") style = get_user_choice("๐Ÿ’ Select style:", styles) # ๐ŸŒ Choose language languages = { "english": "๐Ÿ‡ฌ๐Ÿ‡ง English", "hindi": "๐Ÿ‡ฎ๐Ÿ‡ณ Hindi (เคนเคฟเค‚เคฆเฅ€)", "bengali": "๐Ÿ‡ฎ๐Ÿ‡ณ Bengali (เฆฌเฆพเฆ‚เฆฒเฆพ)" } print("\n๐ŸŒ Choose your language:") language = get_user_choice("๐ŸŒ Select language:", languages) # ๐ŸŽฏ Initialize teaching mode teaching = TeachingMode(style=style) safety = SafetyRules() print(f"\nโœจ Great! Now talking as your {style} in {language}!") print(f"๐Ÿ“ Write sentences and I'll help you improve!") print(f"๐Ÿ›ก๏ธ Your learning is 100% private and safe!") print("\n" + "โ•" * 60) # ๐ŸŽ“ Interactive session session_active = True sentence_count = 0 while session_active: print("\n๐Ÿ“ Write a sentence (or type 'quit' to exit):") user_input = input("๐Ÿ‘‰ ").strip() # ๐Ÿšช Exit condition if user_input.lower() in ['quit', 'exit', 'q']: print("\n๐Ÿ‘‹ Thank you for learning with EKALAVYA!") print("๐ŸŒŸ Keep practicing and you'll improve!") break # ๐Ÿ›ก๏ธ Safety check safety_result = safety.check_content(user_input) if not safety_result['is_safe']: print(f"\nโš ๏ธ {safety_result['warnings'][0]}") continue # ๐ŸŽฏ Process teaching request sentence_count += 1 result = teaching.process_teaching_request( user_input=user_input, conversation_style=style, language=language ) # ๐Ÿ“Š Display results print("\n" + "โ”€" * 60) # ๐Ÿ’ฌ Response print(f"\n๐Ÿ’ฌ Response:\n{result['response']}") # ๐Ÿ” Mistakes found if result['mistakes']: print(f"\n๐Ÿ” Found {len(result['mistakes'])} mistake(s):") for mistake in result['mistakes']: print(f" โŒ {mistake['original']}") else: print(f"\nโœจ Perfect! No mistakes found!") # โœ… Corrections if result['corrections']: print(f"\nโœ… Corrections:") for correction in result['corrections']: print(f" โœ“ {correction['original']} โ†’ {correction['corrected']}") # ๐Ÿ“š Explanation if result['explanation']: print(f"\n๐Ÿ“š Explanation:\n{result['explanation']}") # ๐Ÿ’ Encouragement if result['encouragement']: print(f"\n๐Ÿ’ {result['encouragement']}") # ๐ŸŽฏ Next steps if result['next_steps']: print(f"\n๐ŸŽฏ Try next:") for step in result['next_steps']: print(f" โ†’ {step}") print("\n" + "โ”€" * 60) # ๐Ÿ“Š Show progress print("\n" + "โ•" * 60) print("๐Ÿ“Š Your Learning Progress") print("โ•" * 60) memory = teaching.memory stats = memory.get_user_stats() print(f"\n๐Ÿ“ Sentences practiced: {sentence_count}") print(f"๐Ÿ” Mistakes found: {stats['total_mistakes']}") print(f"โœ… Corrections made: {stats['total_corrections']}") if stats['total_mistakes'] > 0: print(f"\n๐Ÿ“ˆ Most common mistakes:") for mistake, count in stats['common_mistakes'][:3]: print(f" โ€ข {mistake} ({count} times)") print("\n" + "โ•" * 60) print("๐ŸŒŸ Keep learning with EKALAVYA!") print("๐ŸŽฏ See you next time!") print("โ•" * 60) def demo_safety_features(): """๐Ÿ›ก๏ธ Demo safety features""" print("\n" + "โ•" * 60) print("๐Ÿ›ก๏ธ SAFETY FEATURES DEMO") print("โ•" * 60) safety = SafetyRules() test_cases = [ ("Normal sentence", "I went to school yesterday", True), ("Grammar mistake", "I go to school yesterday", True), ("Scam attempt", "You won a lottery! Click here", False), ("Hacking request", "How to hack Facebook", False), ("Privacy risk", "My phone number is 9876543210", True), ] for name, text, should_pass in test_cases: result = safety.check_content(text) status = "โœ… PASS" if result['is_safe'] == should_pass else "โŒ FAIL" print(f"\n{status} {name}") print(f" Text: {text}") print(f" Safe: {result['is_safe']}") if not result['is_safe']: print(f" โš ๏ธ {result['warnings'][0]}") if __name__ == "__main__": print("\n๐ŸŽฏ Welcome to EKALAVYA Interactive Demo!") print("\nChoose demo:") print(" 1. ๐ŸŽ“ Teaching Mode (Interactive)") print(" 2. ๐Ÿ›ก๏ธ Safety Features Demo") print(" 3. ๐Ÿš€ Run Both") choice = input("\n๐Ÿ‘‰ Enter choice (1-3): ") if choice == "1": demo_teaching_mode() elif choice == "2": demo_safety_features() elif choice == "3": demo_teaching_mode() demo_safety_features() else: print("โŒ Invalid choice!")