A newer version of the Gradio SDK is available:
5.34.2
π Deployment Guide for Hugging Face Spaces
Quick Deploy to Hugging Face Spaces
Option 1: Direct Upload
- Create a new Space on Hugging Face Spaces
- Choose "Gradio" as the SDK
- Upload these files from the
deep_research
folder:app.py
deep_research.py
requirements.txt
README.md
metadata.json
- All the agent files (
*_agent.py
,research_manager.py
)
Option 2: Git Repository
- Create a new repository or fork this one
- Copy the
deep_research
folder contents to the root of your repository - Create a new Space and connect it to your repository
Environment Configuration
In your Hugging Face Space settings, add these secrets:
Required
OPENAI_API_KEY
: Your OpenAI API key
Optional (for email functionality)
SENDGRID_API_KEY
: Your SendGrid API keySENDGRID_FROM_EMAIL
: Your verified sender email
Files Structure for Deployment
your-space/
βββ app.py # Main entry point for HF Spaces
βββ deep_research.py # Core application logic
βββ requirements.txt # Python dependencies
βββ README.md # Space documentation
βββ metadata.json # HF Spaces configuration
βββ research_manager.py # Research orchestration
βββ clarifier_agent.py # Clarification agent
βββ planner_agent.py # Planning agent
βββ search_agent.py # Search agent
βββ writer_agent.py # Writing agent
βββ evaluator_agent.py # Quality evaluation agent
βββ email_agent.py # Email delivery agent
βββ .gitignore # Git ignore rules
βββ env_example.txt # Environment variables template
Testing Your Deployment
- Local Testing: Run
python app.py
to test locally - Check Dependencies: Ensure all imports work correctly
- Environment Variables: Test with your actual API keys
- Gradio Interface: Verify the UI loads and functions work
Common Issues & Solutions
Import Errors
- Make sure all agent files are in the same directory
- Verify
openai-agents
package is installed correctly
API Key Issues
- Check that environment variables are set correctly in HF Spaces
- Ensure OpenAI API key has sufficient credits
Email Functionality
- Email features are optional and will be disabled if SendGrid isn't configured
- Verify your SendGrid sender email is verified
Performance Tips
- The app uses OpenAI's Agents framework which can take 1-2 minutes for complex research
- Consider upgrading to a paid HF Spaces plan for better performance
- Monitor usage to avoid API rate limits
Support
If you encounter issues:
- Check the Space logs in Hugging Face
- Verify all environment variables are set
- Test locally first to isolate the issue
- Check OpenAI API status and quotas