Explainer_Docker / README.md
StanDataCamp's picture
Enhance AI Concept Explainer with version 2.0.0: Introduced new features including real-time reading time estimates, a character counter, and a copy-to-clipboard function. Improved UI with a modern gradient header and responsive design. Added structured logging and comprehensive error handling for better user experience.
7997e54
---
title: AI Concept Explainer
emoji: ๐Ÿง 
colorFrom: indigo
colorTo: gray
sdk: docker
pinned: false
license: mit
short_description: AI-powered concept explainer with adaptive complexity
---
# ๐Ÿง  AI Concept Explainer v2.0
A clean, Gradio app that explains any concept at different complexity levels using OpenAI's GPT-4.1-mini. Get personalized explanations tailored to your understanding level and preferred language, with a modern interface optimized for ease of use.
## โœจ Features
### ๐ŸŽ“ Core Functionality
- **5 Complexity Levels**: From "like I'm 5" to expert-level explanations
- **6 Languages**: English, Russian, German, Spanish, French, Italian
- **Real-time Streaming**: Watch explanations generate live with streaming responses
- **Quick Examples**: 3 pre-selected questions to get started instantly
### ๐ŸŽจ Professional UI/UX
- **Compact Design**: Clean layout that fits on one screen without scrolling
- **Modern Gradient Header**: Beautiful purple gradient with professional styling
- **Dark/Light Mode**: Automatic theme detection with smooth transitions
- **Responsive Layout**: Optimized for desktop, tablet, and mobile (900px max-width)
- **Smooth Animations**: Entrance animations and hover effects throughout
### ๐Ÿš€ Productivity Features
- **๐Ÿ“‹ Copy to Clipboard**: One-click copy of any explanation
- **๐Ÿ“– Reading Time**: Real-time reading time estimates as text streams
- **โŒจ๏ธ Keyboard Shortcuts**: Ctrl/Cmd+Enter to submit, Escape to clear
- **๐Ÿ“Š Character Counter**: Color-coded visual feedback (green/orange/red, 0/500 chars)
- **๐Ÿ‘๐Ÿ‘Ž Feedback**: Simple helpful/not helpful reactions for continuous improvement
- **๐Ÿ”„ Clear Button**: Quick reset to start fresh
### ๐Ÿ›ก๏ธ Code Quality & Reliability
- **Type Hints**: Full type annotations throughout the codebase
- **Professional Logging**: Structured logging system (not print statements)
- **Error Handling**: User-friendly error messages with collapsible technical details
- **Input Validation**: Character limits, language verification, and edge case handling
- **Clean Architecture**: Well-organized code with clear sections and documentation
## ๐Ÿš€ Setup
### Hugging Face Spaces
1. Fork or import this repository to your Hugging Face Space
2. Go to **Settings** โ†’ **Repository secrets**
3. Add secret: `OPENAI_API_KEY` with your OpenAI API key
4. The app will automatically deploy!
### Local Development
```bash
# Clone and navigate to the project
cd Explainer_docker
# Create virtual environment (Python 3.11+)
python3 -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Set your API key
echo "OPENAI_API_KEY=your_api_key_here" > .env
# Run the app
python app.py
```
Visit `http://127.0.0.1:7860` in your browser.
**To stop**: Press `Ctrl+C` in the terminal, then deactivate the virtual environment:
```bash
deactivate
```
### Docker Deployment
```bash
# Create .env file with your API key
echo "OPENAI_API_KEY=your_key_here" > .env
# Build and run
docker-compose up --build
# Access at http://localhost:7860
```
**To stop**: Press `Ctrl+C`, then:
```bash
docker-compose down
```
## ๐ŸŽฎ How to Use
1. **Click a quick example** or **enter your own question** (up to 500 characters)
2. **Adjust complexity level** (1-5) using the slider to match your knowledge
3. **Select your language** from the dropdown (6 languages available)
4. **Click "๐Ÿš€ Explain Concept"** or press `Ctrl/Cmd + Enter` (keyboard shortcut)
5. **Watch the explanation stream** in real-time with live reading time estimate
6. **Copy to clipboard** with one click for easy sharing
7. **Give feedback** with ๐Ÿ‘ Helpful or ๐Ÿ‘Ž Not Helpful to improve the app
### ๐Ÿ“Š Complexity Levels Explained
| Level | Description | Best For |
|-------|-------------|----------|
| **1** ๐Ÿง’ | Like I'm 5 - Simple words and analogies | Young learners, complete beginners |
| **2** ๐Ÿ‘ฆ | Like I'm 10 - Basic concepts with examples | Elementary understanding |
| **3** ๐ŸŽ“ | High school - Intermediate with technical terms | General audience (default) |
| **4** ๐ŸŽฏ | College - Advanced concepts with details | Students and professionals |
| **5** ๐Ÿ‘จโ€๐Ÿ”ฌ | Expert - Professional depth and precision | Subject matter experts |
## ๐Ÿ”ง Technical Stack
- **Framework**: Gradio 5.47.2 with custom theming
- **AI Model**: OpenAI GPT-4o-mini (optimized for quality and speed)
- **Language**: Python 3.11+ with type hints
- **UI/UX**: Custom CSS with Inter font, responsive design
- **Features**: Real-time streaming, session management, client-side interactivity
- **Architecture**: Modular code structure with proper separation of concerns
## ๐Ÿ”’ Security
- API keys stored as environment variables only
- No data persistence or storage
- Secure HTTPS API calls to OpenAI
- `.env` files are gitignored and never committed
## ๐Ÿ“ License
MIT License - Part of the LLM and Agentic AI Bootcamp Materials.
## ๐ŸŽ‰ What's New in v2.0
### โœจ New Features
- โœ… **Compact, professional header** with beautiful gradient design
- โœ… **Copy to clipboard** - Share explanations with one click
- โœ… **Real-time reading time** - Know how long each explanation will take
- โœ… **Character counter** - Visual feedback with color coding (green/orange/red)
- โœ… **3 Quick examples** - Get started instantly with pre-selected questions
- โœ… **Keyboard shortcuts** - Power user features (Ctrl/Cmd+Enter, Escape)
- โœ… **User feedback system** - ๐Ÿ‘/๐Ÿ‘Ž to help improve the experience
- โœ… **Clear button** - Quick reset to start fresh
- โœ… **Enhanced error handling** - Friendly messages with technical details for debugging
### ๐Ÿ’ป Code Quality Improvements
- โœ… **Full type hints** - Complete type annotations throughout the codebase
- โœ… **Professional logging** - Structured logging system replacing print statements
- โœ… **Modular organization** - Clean code structure with clear sections
- โœ… **Comprehensive documentation** - Detailed docstrings for all functions
- โœ… **Better error handling** - Categorized errors with helpful user messages
- โœ… **Input validation** - Character limits, language verification, edge cases
### ๐ŸŽจ UI/UX Enhancements
- โœ… **One-screen design** - Everything fits without scrolling for optimal UX
- โœ… **Wider but shorter** - 900px width, minimal vertical space
- โœ… **Modern gradient header** - Professional purple gradient (indigo to purple)
- โœ… **Inter font** - Modern, readable typography from Google Fonts
- โœ… **Smooth animations** - Entrance effects and hover transitions
- โœ… **Enhanced dark mode** - Automatic detection with beautiful themes
- โœ… **Clean, focused layout** - No sidebars, distractions, or clutter
- โœ… **Responsive design** - Works beautifully on desktop, tablet, and mobile
---
**v2.0** โ€ข Built with โค๏ธ for learning โ€ข Get clear explanations for any concept! ๐ŸŽฏ