A newer version of the Gradio SDK is available:
6.1.0
π HF Spaces Deployment Checklist
Pre-Deployment Checklist
β Files Ready
-
app.py- Main application (β Verified working) -
requirements_hf.txt- HF-optimized dependencies (β Created) -
README_HF.md- Space documentation (β Ready) -
agents/directory - Agent system (β Present) -
kg_services/directory - KG services (β Present) -
data/directory - Initial data files (β Present) -
schemas/directory - Data schemas (β Present)
β Environment Configuration
- OpenAI API key obtained (β οΈ Required)
- API billing enabled (β οΈ Required)
-
.env.hftemplate created (β Ready)
β Technical Verification
Dependencies Test
uv pip install -r requirements_hf.txt
Status: β PASSED - All dependencies install correctly
Import Test
python -c "import app; print('App imports successfully')"
Status: β PASSED - No import errors
Startup Test
timeout 10s python app.py
Status: β PASSED - App starts with all components:
- β Embedding service initializes
- β Knowledge graph loads (4 tools, 8 prompts)
- β Vector index builds successfully
- β FastAPI server starts on 0.0.0.0:7862
- β Gradio UI mounts at /ui
- β API docs available at /docs
HF Space Configuration
Space Settings
# Space Configuration
title: KGraph-MCP
emoji: π§
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 5.33.0
app_file: app.py
pinned: false
license: apache-2.0
Required Secrets
OPENAI_API_KEY: [Your OpenAI API Key]
Optional Secrets (Recommended)
LOG_LEVEL:INFOAPP_ENV:production
Deployment Steps
1. Create HF Space
- Go to https://huggingface.co/spaces
- Click "Create new Space"
- Configure with settings above
- Set visibility (Public/Private)
2. Upload Files
- Upload all required files and directories
- Rename
README_HF.mdtoREADME.md
3. Configure Secrets
- Add
OPENAI_API_KEYin Space settings > Secrets - Add optional environment variables
4. Deploy & Test
- HF will automatically build and deploy
- Test all functionality once live
Post-Deployment Verification
Functional Tests
- Space loads without errors
- Gradio UI is accessible
- API endpoints respond correctly
- Tool suggestion works
- Plan generation works
- Example queries work
- Error handling works
Performance Tests
- Cold start time < 30 seconds
- Query responses < 10 seconds
- Memory usage stable
- No memory leaks
Troubleshooting Guide
Common Issues
"Module not found"
- Verify all directories uploaded
- Check requirements_hf.txt
OpenAI API errors
- Check API key in secrets
- Verify billing enabled
- Check rate limits
Slow startup
- Normal for first run (embedding generation)
- Should be faster on subsequent starts
Memory issues
- Check if all dependencies are minimal
- Monitor Space resource usage
Success Metrics
Performance Targets
- β Startup time: < 30 seconds
- β Query response: < 10 seconds
- β Memory usage: < 1GB
- β API response time: < 5 seconds
Functionality Requirements
- β Tool suggestion accuracy
- β Plan generation quality
- β Error handling robustness
- β UI responsiveness
Final Checklist
Before marking Task 5.5 as complete:
- All files uploaded to HF Space
- Secrets configured correctly
- Space deploys successfully
- All features tested and working
- Performance within acceptable limits
- Documentation updated with Space URL
- Team notified of deployment
Status: Ready for HF Spaces deployment π
Next Steps:
- Create HF Space
- Upload files
- Configure secrets
- Test deployment
- Mark Task 5.5 as Done