gaurangpatelahm/art-studio
๐จ AI Visual Art Studio IDE
   
A simplified creative IDE that uses OpenAI Agents SDK with intelligent delegation flow for multi-agent creative collaboration. Instead of rigid pipelines, agents naturally delegate to each other based on task requirements and expertise.
๐ Ready for instant Docker deployment to Hugging Face Spaces!
๐ Live Demo
Try the AI Visual Art Studio live on Hugging Face Spaces (Docker-based):

Deploy your own instance:
# Quick deployment to Hugging Face Spaces
./deploy_to_hf.sh your-username๐ Key Features
๐ Key Features
๐ค Intelligent Agent Delegation
- Concept Artist: Creative director who can delegate specialized tasks
- Sketch Artist: Visual creator who can delegate refinement work
- Refinement Artist: Detail specialist who can delegate evaluation
- Curator: Final evaluator who can request improvements from any agent
๐ Natural Delegation Flow
- No fixed order - agents decide when to delegate based on task needs
- Intelligent handoffs - each agent focuses on their expertise
- Collaborative creation - multiple agents work together naturally
- Flexible workflows - adapts to different creative requirements
๐ง OpenAI Agents SDK Integration
- Built-in tracing for all executions and delegations
- Decorator-based tools (
@tool,@guardrail,@trace) - Agent-to-agent communication through delegation tools
- Content safety with built-in guardrails
๐จ Creative Workflow Examples
- Concept โ Sketch โ Refinement โ Curator (full creative process)
- Concept โ Curator (quick evaluation)
- Sketch โ Refinement โ Curator (visual improvement focus)
- Curator โ Refinement (quality improvement requests)
๐ Quick Start
Option 1: Deploy to Hugging Face Spaces (Recommended)
Deploy instantly with one command:
# Clone this repository
git clone https://github.com/your-username/ai-art-studio.git
cd ai-art-studio
# Deploy to Hugging Face Spaces
./deploy_to_hf.sh your-usernameThen set your OpenAI API key in the Space settings:
- Go to your Space settings
- Add environment variable:
OPENAI_API_KEY=your_actual_key - Wait for build to complete (2-5 minutes)
Option 2: Local Development
1. Setup Environment
# Clone the repository
git clone <your-repo>
cd art_studio
# Install dependencies
pip install -r requirements.txt
# Set your OpenAI API key
echo "OPENAI_API_KEY=your_key_here" > .env2. Run the Studio
# Launch the Gradio web interface
python main.py
# Or run examples directly
python example_usage.py3. Use the Delegation Flow
- Start with any agent as your primary creative partner
- Describe your vision - agents will delegate as needed
- Watch the collaboration unfold naturally
- Review the results with full execution tracing
๐ Hugging Face Spaces Deployment
What is Hugging Face Spaces?
Hugging Face Spaces is a free platform for hosting ML applications. It provides:
- ๐ Free hosting for your AI applications
- ๐ Automatic deployment from Git repositories
- ๐ Secure environment variables for API keys
- ๐ฑ Public sharing of your AI tools
Deployment Features
- Gradio Interface: Beautiful web UI for your AI Art Studio
- Docker Support: Containerized deployment for reliability
- Environment Variables: Secure API key management
- Auto-scaling: Handles traffic automatically
- Monitoring: Built-in logs and performance tracking
Space Configuration
# Space Settings
SDK: Docker
Hardware: CPU (free) or GPU (paid)
Visibility: Public or Private
# Docker Configuration
Dockerfile: Included (Python 3.9 + Gradio)
Port: 7860
Health Check: EnabledRequired Environment Variables
OPENAIAPIKEY: youropenaiapikey OPENAIMODEL: gpt-4o-mini OPENAITEMPERATURE: 0.7 OPENAIMAXTOKENS: 2000 DALLEMODEL: dall-e-3
### **Deployment Commands**Quick deployment
./deploytohf.sh your-username
Manual deployment
git clone https://huggingface.co/spaces/your-username/ai-art-studio cd ai-art-studio
Copy files and push
git add . && git commit -m "Deploy AI Art Studio" && git push
## ๐๏ธ **Architecture**
### **Project Structure**ai-art-studio/ โโโ app.py # Main entry point (runs on port 7860) โโโ main.py # Alternative local entry point โโโ requirements.txt # Python dependencies โโโ Dockerfile # Container configuration โโโ src/ # Source code โ โโโ core/ # Core AI logic โ โโโ ui/ # Gradio interface โโโ .gitignore # Git exclusions โโโ README.md # This file with HF config
### **Core Components**ArtStudio โโโ Agent Management (OpenAI Agents SDK) โโโ Delegation Flow Engine โโโ Tool System (@tool decorators) โโโ Guardrails (@guardrail decorators) โโโ Tracing (@trace decorators) โโโ Gradio Web Interface
### **Delegation Patterns**Concept Artist โโโ Can delegate to: Sketch Artist, Refinement Artist, Curator โโโ Role: Creative direction and coordination
Sketch Artist โโโ Can delegate to: Refinement Artist, Curator โโโ Role: Visual creation and composition
Refinement Artist โโโ Can delegate to: Curator โโโ Role: Technical improvement and detail work
Curator โโโ Can delegate to: Concept Artist, Sketch Artist, Refinement Artist โโโ Role: Quality evaluation and improvement requests
## ๐ฏ **Usage Examples**
### **Basic Delegation Flow**from src.core.art_studio import ArtStudio
Initialize the studio
studio = ArtStudio()
Execute delegation flow
result = await studio.executedelegationflow( "Design a magical forest scene with glowing mushrooms", "concept_artist" # Start with concept artist )
Agents will automatically delegate as needed
print(f"Completed in {result['total_iterations']} iterations")
### **Single Agent Execution**Execute a specific agent
result = await studio.executeagent( "sketchartist", "Create a sketch based on this concept: futuristic cityscape" )
### **Agent Information**Get agent capabilities
agentinfo = studio.getagentinfo("conceptartist") print(f"Can delegate to: {agentinfo['candelegate_to']}")
## ๐ **Tracing & Debugging**
### **Built-in Tracing**
- **All agent executions** are automatically traced
- **Delegation decisions** are logged and tracked
- **Performance metrics** for each agent
- **Full execution chain** visibility
### **Debug Information**
- **Agent delegation patterns**
- **Tool usage statistics**
- **Execution time tracking**
- **Error handling and recovery**
## ๐ก๏ธ **Safety & Guardrails**
### **Content Safety**
- **Built-in filtering** for inappropriate content
- **Bias detection** and mitigation
- **Copyright protection** measures
- **Quality standards** enforcement
### **Guardrail System**
- **@guardrail decorators** for input/output filtering
- **Configurable safety rules**
- **Automatic content review**
- **Escalation procedures**
## ๐จ **Creative Workflows**
### **Full Creative Process**
1. **Concept Artist** generates creative vision
2. **Delegates to Sketch Artist** for visual representation
3. **Sketch Artist delegates to Refinement Artist** for details
4. **Refinement Artist delegates to Curator** for evaluation
5. **Curator may request improvements** from any agent
### **Quick Evaluation**
1. **Concept Artist** creates concept
2. **Delegates directly to Curator** for assessment
3. **Curator provides feedback** and recommendations
### **Visual Improvement Focus**
1. **Sketch Artist** creates initial sketch
2. **Delegates to Refinement Artist** for enhancement
3. **Refinement Artist delegates to Curator** for final review
## ๐ **Advanced Features**
### **Custom Tools**
- **Easy tool creation** with `@tool` decorator
- **Agent-specific tools** for specialized tasks
- **Tool composition** and chaining
- **External API integration**
### **Model Configuration**
- **Per-agent model selection**
- **Parameter customization**
- **Hot-swapping capabilities**
- **Performance optimization**
### **Extensibility**
- **Plugin system** for custom agents
- **External tool integration**
- **Workflow customization**
- **API endpoints** for external access
## ๐ **Performance & Monitoring**
### **Execution Metrics**
- **Agent response times**
- **Delegation frequency**
- **Tool usage patterns**
- **Error rates and recovery**
### **Resource Management**
- **Memory usage optimization**
- **Concurrent execution** support
- **Rate limiting** and throttling
- **Resource cleanup** and management
## ๐ฎ **Roadmap**
### **Phase 1: Core Delegation** โ
- [x] Basic delegation flow
- [x] Agent-to-agent communication
- [x] Built-in tracing
- [x] Content safety
### **Phase 2: Advanced Features**
- [ ] Multi-modal support (images, audio)
- [ ] Advanced guardrails
- [ ] Performance optimization
- [ ] External tool integration
### **Phase 3: Enterprise Features**
- [ ] Team collaboration
- [ ] Advanced analytics
- [ ] Custom agent training
- [ ] Enterprise security
## ๐จ **Troubleshooting**
### **Hugging Face Spaces Issues**
**"Missing configuration in README"**
- โ
**Fixed**: This README now contains complete HF Spaces configuration
- Ensure you're using the latest version of this repository
**"Space is missing an app file"**
- โ
**Fixed**: `app.py` is properly configured and exposes the `demo` object
- Verify `app.py` exists in your Space root directory
**Build failures**
- Check that `requirements.txt` contains all dependencies
- Ensure Python version is set to 3.9
- Verify environment variables are set correctly
**Import errors**
- Confirm all source files are in the `src/` directory
- Check that `app.py` imports are working locally first
### **Local Development Issues**
**OpenAI API errors**
- Verify your `.env` file contains `OPENAI_API_KEY`
- Check API key validity and account credits
- Ensure you're using supported models
**Gradio interface issues**
- Check that port 7860 is available
- Verify all dependencies are installed
- Check console for error messages
### **Getting Help**
- ๐ **Documentation**: Check this README and `README_HF_SPACES.md`
- ๐ **Issues**: Report bugs in the GitHub repository
- ๐ฌ **Community**: Join our discussions for support
## ๐ค **Contributing**
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
### **Development Setup**Install development dependencies
pip install -r requirements-dev.txt
Run tests
pytest
Code formatting
black src/ isort src/
## ๐ **License**
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ **Acknowledgments**
- **OpenAI Agents SDK** for the powerful agent framework
- **Gradio** for the beautiful web interface
- **Community contributors** for ideas and feedback
---
**๐จ Create, Collaborate, Delegate - Let AI agents work together naturally!**
