--- title: Wizard Spells AI Agent colorFrom: pink colorTo: yellow sdk: streamlit app_file: app.py pinned: false tags: - streamlit - wizard - spells - magic - ai - image-generation --- # Wizard Spells AI Agent An intelligent AI application that generates a single random wizard spell and creates a magical visualization using Streamlit and AI image generation. ## Features - **Single Spell Generation**: Fetches one random wizard spell from the Wizard World API - **AI-Powered Visualizations**: Generates magical images using FLUX.1-schnell model - **Clean Interface**: Simple, focused Streamlit interface - **Responsive Design**: Works great on desktop and mobile - **Real-time Generation**: Live image generation with loading indicators - **One-Click Experience**: Single button generates spell and visualization ## How It Works 1. **Click Generate**: Press the "Generate Random Spell!" button 2. **Spell Selection**: The app fetches one random spell from the database 3. **Image Creation**: AI generates a custom visualization for your spell 4. **Clean Display**: Spell name and effect shown with accompanying image ## Technology Stack - **Frontend**: Streamlit (latest version) - **Image Generation**: HuggingFace FLUX.1-schnell model - **Spell Data**: Wizard World API - **Image Processing**: Pillow (PIL) - **Deployment**: HuggingFace Spaces ## Features in Detail ### 🎲 Single Spell Generation - Fetches one spell from a comprehensive wizard spell database - Each spell includes name and magical effect description - Clean, focused display without clutter ### 🎨 AI Image Generation - Uses state-of-the-art FLUX.1-schnell model - Generates unique visualizations for each spell - Handles API errors gracefully with fallback displays ### 📱 User Experience - Simple one-button interface - Loading indicators for better UX - Sidebar with helpful information - Responsive design for all devices - Fast, streamlined workflow ## Usage Examples Perfect for: - D&D campaign inspiration - Creative writing prompts - Fantasy world building - Educational content about magic systems - Quick magical inspiration - Entertainment and fun ## Interface Layout - **Main Area**: Single spell display with name and effect - **Image Panel**: AI-generated visualization of the spell - **Sidebar**: App information and status indicators - **Single Button**: One-click spell generation ## Setup for Local Development 1. Clone the repository 2. Install dependencies: `pip install -r requirements.txt` 3. Set HF_TOKEN environment variable (optional, for image generation) 4. Run: `streamlit run app.py` ## Technical Notes - **No Version Pinning**: Uses latest stable versions of all libraries - **Error Handling**: Graceful fallbacks when services are unavailable - **Modular Design**: Clean separation of concerns - **Performance**: Efficient API calls and image handling - **Minimal Dependencies**: Only essential libraries included ## API Integration - **Wizard World API**: Provides authentic wizard spell data - **HuggingFace FLUX**: Powers the AI image generation - **Streamlit**: Handles the web interface and user interactions This project demonstrates modern Python web app development with AI integration, showcasing best practices for Streamlit applications with a focus on simplicity and user experience.