Spaces:
Running
Running
metadata
title: Unified Assistant - AI-Powered Document Creation Platform
emoji: π€
colorFrom: blue
colorTo: purple
sdk: docker
sdk_version: 20.10.23
app_file: app.py
pinned: false
Unified Assistant - AI-Powered Document Creation Platform
π Quick Deploy to Hugging Face Spaces
This project is configured for easy deployment to Hugging Face Spaces with Supabase database integration.
π Prerequisites
- Hugging Face Account: Create an account at huggingface.co
- Supabase Project: Create a project at supabase.com
- OpenAI API Key: Get your API key from platform.openai.com
π Deploy to Hugging Face Spaces
Option 1: Deploy via Hugging Face Web Interface
Go to Hugging Face Spaces
Click "Create new Space"
Choose settings:
- Owner: Your username
- Space name:
unified-assistant
(or your preferred name) - Space SDK:
Docker
- License: Choose appropriate license
- Visibility: Public or Private
Upload your code:
- Clone this repository
- Upload all files to your new Space
Configure Environment Variables:
- Go to your Space β Settings β Repository secrets
- Add the following secrets:
SUPABASE_DB_URL=postgresql+asyncpg://postgres:WiHcl5UgLmP1rLGZ@nqdhdqdtpvqfecbsjaar.supabase.co:5432/postgres
ENVIRONMENT=production
OPENAI_API_KEY=your_openai_api_key_here
SECRET_KEY=Qee7sf39ipUhe_1pKCnsMLPU-aanOt-xs0gx3bsBuFo
DEBUG=false
HOST=0.0.0.0
PORT=7860
Option 2: Deploy via Git
- Fork this repository to your GitHub account
- Create a new Space on Hugging Face
- Connect your GitHub repository
- Configure environment variables as shown above
π§ Environment Variables
Variable | Description | Required | Example |
---|---|---|---|
SUPABASE_DB_URL |
PostgreSQL connection string | β Yes | postgresql+asyncpg://postgres:password@host:5432/postgres |
ENVIRONMENT |
Set to "production" | β Yes | production |
OPENAI_API_KEY |
Your OpenAI API key | β Yes | sk-... |
SECRET_KEY |
Secret key for JWT tokens | β Yes | your-secret-key |
DEBUG |
Debug mode | Optional | false |
HOST |
Host binding | Optional | 0.0.0.0 |
PORT |
Port number | Optional | 7860 |
π³ Docker Configuration
The project includes a Dockerfile
optimized for Hugging Face Spaces:
- Base Image: Python 3.11-slim
- Port: 7860 (Hugging Face Spaces standard)
- Health Check: Automatic health monitoring
- Environment: Production-ready configuration
π Monitoring Your Deployment
Check Deployment Status
- Visit your Space URL:
https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
- Check logs: Go to your Space β Settings β Logs
- Health endpoint: Visit
/health
on your deployed app
Expected Logs on Startup
π§ Database Configuration:
Environment: production
Is Production: True
Is Hugging Face Deployment: True
Supabase DB URL set: Yes
Effective Database URL: postgresql+asyncpg://postgres:***@nqdhdqdtpvqfecbsjaar.supabase.co:5432/postgres
Database Type: PostgreSQL/Supabase
β
Using PostgreSQL/Supabase configuration
β
Database tables created successfully
π Application startup complete
π Testing Your Deployment
1. Health Check
curl https://YOUR_SPACE_NAME.hf.space/health
2. API Documentation
Visit: https://YOUR_SPACE_NAME.hf.space/docs
3. Root Endpoint
Visit: https://YOUR_SPACE_NAME.hf.space/
π οΈ Troubleshooting
Common Issues
Database Connection Failed
- Check your
SUPABASE_DB_URL
is correct - Verify your Supabase project is active
- Check Hugging Face Space logs for errors
- Check your
Environment Variables Not Set
- Go to Space Settings β Repository secrets
- Add all required environment variables
- Redeploy your Space
Port Issues
- Hugging Face Spaces uses port 7860 by default
- The Dockerfile is already configured correctly
Build Failures
- Check the
requirements.txt
file is present - Verify all dependencies are compatible
- Check build logs in your Space
- Check the
Debug Commands
# Check environment variables
python debug_env.py
# Test database connection
python test_database_config.py
# Quick connection test
python quick_test.py
π Performance Optimization
For Production Deployment
- Database Connection Pooling: Already configured for Supabase
- Async Operations: All database operations are async
- Caching: Consider adding Redis for session caching
- Monitoring: Use Hugging Face Space logs for monitoring
π Security Notes
- β
Never commit
.env
files to version control - β Use Hugging Face secrets for all sensitive data
- β Supabase automatically handles SSL connections
- β Database credentials are encrypted in transit
- β JWT tokens are properly secured
π Support
If you encounter issues:
- Check Hugging Face Space logs
- Verify environment variables
- Test database connection locally first
- Review the troubleshooting section above
π Success!
Once deployed, your Unified Assistant will be available at:
https://YOUR_SPACE_NAME.hf.space
The application will automatically:
- β Connect to your Supabase database
- β Create all necessary tables
- β Start the FastAPI server
- β
Provide API documentation at
/docs
- β Handle authentication and user management
- β Support all AI assistant features
Happy Deploying! π