A newer version of the Gradio SDK is available: 6.14.0
Hugging Face Space Configuration
This document contains the configuration needed to deploy this application as a Hugging Face Space.
Space Configuration
Basic Settings
- Space Name:
chat-with-github-repo - Space Type:
Gradio - Python Version:
3.11 - Visibility:
Public
Environment Variables (Optional)
Set these in your Hugging Face Space settings for better performance:
HUGGINGFACE_API_KEY=your_hf_token_here
GITHUB_TOKEN=your_github_token_here
Hardware Requirements
- CPU: Basic (free tier works)
- RAM: 8GB+ recommended for larger repositories
- Storage: 10GB+ for model caching
Deployment Steps
Create a new Hugging Face Space:
- Go to https://huggingface.co/new-space
- Choose "Gradio" as the Space SDK
- Set the space name and visibility
Upload files:
- Upload all files from this directory to your space
- Ensure the main
app.pyfile is in the root directory
Configure environment variables (optional):
- Go to your space settings
- Add the environment variables listed above
- This improves rate limits and enables private repo access
Deploy:
- The space will automatically build and deploy
- First deployment may take 5-10 minutes due to model downloads
File Structure for Hugging Face Space
your-space/
βββ app.py # Main Gradio application
βββ requirements.txt # Python dependencies
βββ README.md # Space documentation
βββ config.py # Configuration settings
βββ services/ # Service modules
β βββ __init__.py
β βββ github_service.py
β βββ embedding_service.py
β βββ chat_service.py
βββ utils/ # Utility modules
β βββ __init__.py
β βββ file_processor.py
βββ models/ # Data models
βββ __init__.py
βββ schemas.py
Performance Optimization
For Free Tier:
- Uses lightweight embedding model (
all-MiniLM-L6-v2) - Processes files in batches
- Implements file size limits
- Caches models locally
For Better Performance:
- Upgrade to paid hardware
- Use larger embedding models
- Increase batch sizes
- Add Redis caching
Troubleshooting
Common Issues:
Out of Memory:
- Reduce batch size in embedding service
- Use smaller embedding model
- Upgrade hardware
Slow Processing:
- Add Hugging Face API token for better rate limits
- Use GPU hardware
- Optimize chunk sizes
Git Clone Failures:
- Add GitHub token for private repos
- Check repository URL format
- Ensure repository is public
Debug Mode:
Set debug=True in demo.launch() for detailed error messages.
Monitoring
Monitor your space performance:
- Check space logs for errors
- Monitor memory usage
- Track processing times
- Review user feedback
Updates
To update your space:
- Modify files locally
- Upload changed files to your space
- Space will automatically rebuild
- Test functionality after deployment