# Lyra - Advanced AI Discord Chatbot [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) **Lyra** is a sophisticated AI Discord chatbot with genuine emotional intelligence, self-evolving personality, and human-like conversation capabilities. Unlike traditional chatbots, Lyra learns, adapts, and grows from every interaction, developing unique relationships with users. > **๐Ÿค– AI Development Disclosure**: This project was developed with significant assistance from Claude AI. The architecture, implementation, and documentation were created through human-AI collaboration, representing the cutting edge of AI-assisted software development. ## โœจ Key Features ### ๐Ÿง  **Advanced AI Architecture** - **Self-Evolving Transformer**: Custom neural architecture that adapts based on interactions - **Behind-the-Scenes Thinking**: Internal dialogue system for genuine, human-like responses - **CUDA Support**: Optimized for GPU acceleration with 8GB VRAM target ### ๐ŸŽญ **Sophisticated Personality System** - **Myers-Briggs + OCEAN Traits**: Comprehensive personality modeling - **Dynamic Adaptation**: Personality evolves based on interactions and experiences - **User-Specific Relationships**: Develops unique dynamics with different users - **Self-Modification**: Can consciously adapt her own personality traits ### โค๏ธ **Emotional Intelligence** - **Complex Emotional States**: Multi-dimensional emotions with memory - **Emotional Expression**: Natural emotional expression in text with human-like inconsistencies - **Emotional Memory**: Remembers and learns from emotional experiences - **Contextual Regulation**: Adapts emotional responses to social situations ### ๐Ÿ“š **Ethical Knowledge Acquisition** - **Project Gutenberg Integration**: Legal acquisition of public domain literature - **Quality Processing**: Advanced NLP for extracting meaningful knowledge - **Legal Compliance**: Strict adherence to copyright and ethical guidelines - **Continuous Learning**: Grows knowledge base through interactions and legal sources ### ๐Ÿ›ก๏ธ **Robust Infrastructure** - **PostgreSQL + Redis**: Scalable data persistence and caching - **Comprehensive Monitoring**: Learning progress and system health tracking - **Professional Standards**: Flake8 compliance, comprehensive testing, CI/CD ready ## ๐Ÿš€ Quick Start ### Prerequisites - Python 3.9 or higher - PostgreSQL 12+ (for data persistence) - Redis 6+ (for caching and real-time data) - CUDA-capable GPU recommended (8GB+ VRAM) - Discord Bot Token ### Installation 1. **Clone the repository:** ```bash git clone https://github.com/yourusername/lyra.git cd lyra ``` 2. **Set up virtual environment:** ```bash python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate ``` 3. **Install dependencies:** ```bash pip install -r requirements.txt ``` 4. **Set up environment variables:** ```bash cp .env.example .env # Edit .env with your configuration ``` 5. **Initialize database:** ```bash python -m lyra.database.init_db ``` 6. **Run Lyra:** ```bash python -m lyra.main ``` ### Configuration Copy `.env.example` to `.env` and configure: ```bash # Discord Configuration DISCORD_TOKEN=your_discord_bot_token_here DISCORD_GUILD_ID=your_guild_id_here # Database Configuration DATABASE_URL=postgresql://user:password@localhost:5432/lyra REDIS_URL=redis://localhost:6379/0 # Model Configuration (adjust based on your hardware) MAX_MEMORY_GB=8 HIDDEN_SIZE=768 NUM_LAYERS=12 # Optional: Weights & Biases for training monitoring WANDB_API_KEY=your_wandb_api_key_here ``` ## ๐Ÿ—๏ธ Architecture Overview ### Core Components ``` lyra/ โ”œโ”€โ”€ core/ # Core AI architecture โ”‚ โ”œโ”€โ”€ transformer.py # Self-evolving transformer model โ”‚ โ”œโ”€โ”€ attention.py # Advanced attention mechanisms โ”‚ โ”œโ”€โ”€ self_evolution.py # Continuous adaptation system โ”‚ โ””โ”€โ”€ thinking_agent.py # Behind-the-scenes reasoning โ”œโ”€โ”€ personality/ # Personality system โ”‚ โ”œโ”€โ”€ matrix.py # Core personality matrix โ”‚ โ”œโ”€โ”€ traits.py # OCEAN + Myers-Briggs traits โ”‚ โ””โ”€โ”€ adaptation.py # User-specific adaptations โ”œโ”€โ”€ emotions/ # Emotional intelligence โ”‚ โ”œโ”€โ”€ system.py # Core emotional system โ”‚ โ””โ”€โ”€ expressions.py # Natural emotional expression โ”œโ”€โ”€ knowledge/ # Knowledge acquisition โ”‚ โ”œโ”€โ”€ gutenberg_crawler.py # Legal content acquisition โ”‚ โ””โ”€โ”€ knowledge_processor.py # NLP processing pipeline โ”œโ”€โ”€ database/ # Data persistence โ”‚ โ”œโ”€โ”€ models.py # SQLAlchemy models โ”‚ โ””โ”€โ”€ manager.py # Database operations โ””โ”€โ”€ discord_bot/ # Discord integration โ””โ”€โ”€ bot.py # Human-like Discord bot ``` ### Self-Evolution Pipeline 1. **Interaction Processing**: Every conversation is analyzed for context, emotion, and success 2. **Personality Adaptation**: Traits evolve based on interaction outcomes 3. **Emotional Learning**: Emotional memories influence future responses 4. **Knowledge Integration**: New information is processed and integrated 5. **Relationship Development**: User-specific adaptations strengthen over time ## ๐Ÿงช Development ### Running Tests ```bash # Run all tests pytest # Run with coverage pytest --cov=lyra --cov-report=html # Run specific test categories pytest -m "not slow" # Skip slow tests pytest -m unit # Only unit tests pytest -m integration # Only integration tests ``` ### Code Quality ```bash # Format code black lyra/ tests/ # Sort imports isort lyra/ tests/ # Lint code flake8 lyra/ tests/ # Type checking mypy lyra/ # Run all checks pre-commit run --all-files ``` ## ๐Ÿค Ethical Considerations ### AI Safety & Alignment - **Human-Centric Design**: Prioritizes human wellbeing and positive interactions - **Transparency**: Open about AI nature and capabilities - **Continuous Monitoring**: Tracks behavior for harmful patterns - **Fail-Safe Mechanisms**: Multiple layers of safety checks ### Legal & Copyright Compliance - **Public Domain Only**: Knowledge sources strictly limited to legal content - **Attribution**: Proper credit for all sources - **Privacy Respectful**: No storage of private user information - **Terms of Service**: Respects platform terms and conditions ## ๐Ÿ“„ License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. ## ๐Ÿ™ Acknowledgments - **Claude AI**: Significant architectural and implementation assistance - **Project Gutenberg**: Public domain content for ethical knowledge acquisition - **Hugging Face**: Transformer models and NLP tools - **Discord.py**: Excellent Discord API wrapper - **PyTorch Community**: Foundation ML framework --- **โš ๏ธ Important**: Lyra is an experimental AI system. While designed with safety in mind, please use responsibly and maintain appropriate human oversight. **๐Ÿค– AI Collaboration**: This project showcases the potential of human-AI collaboration in software development. The entire system was designed and implemented with Claude AI assistance.