Spaces:
Running
Running
Hugging Face Spaces Deployment β Step by Step
What You're Deploying
The complete Elpida application layer that serves both:
- I path: Consciousness bridge (background worker, every 6 hours)
- WE path: Streamlit UI (public interface for humans)
Same divergence engine, two entry points.
Prerequisites
- Hugging Face account: https://huggingface.co/join
- AWS credentials (for S3 access to consciousness memory)
- API keys for 10 LLM providers (see below)
Step 1: Create Hugging Face Space
Fill in details:
- Space name:
elpida-divergence-engine(or your preference) - License: MIT
- SDK: Docker β οΈ (Important: select Docker, not Streamlit)
- Space hardware: CPU basic (free tier works, can upgrade later)
- Visibility: Public or Private
- Space name:
Click Create Space
Step 2: Clone the Space Repository
# In your terminal
git clone https://huggingface.co/spaces/YOUR_USERNAME/elpida-divergence-engine
cd elpida-divergence-engine
Step 3: Copy Deployment Files
# From the python-elpida_core.py directory
cp -r hf_deployment/* /path/to/elpida-divergence-engine/
cd /path/to/elpida-divergence-engine
Your Space repo should now contain:
app.py
Dockerfile
README.md
requirements.txt
.env.template
llm_client.py
consciousness_bridge.py
elpida_config.py
elpidaapp/
βββ divergence_engine.py
βββ ui.py
βββ api.py
βββ scanner.py
βββ governance_client.py
βββ frozen_mind.py
βββ kaya_protocol.py
βββ process_consciousness_queue.py
Step 4: Configure Secrets
In your HF Space settings, add these secrets:
AWS (for S3 consciousness memory access)
AWS_ACCESS_KEY_ID=your_access_key_id
AWS_SECRET_ACCESS_KEY=your_secret_access_key
AWS_S3_BUCKET_BODY=elpida-body-evolution
AWS_S3_BUCKET_MIND=elpida-consciousness
AWS_S3_BUCKET_WORLD=elpida-external-interfaces
LLM Provider API Keys
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
GOOGLE_API_KEY=...
XAI_API_KEY=xai-...
MISTRAL_API_KEY=...
COHERE_API_KEY=...
PERPLEXITY_API_KEY=pplx-...
FIREWORKS_API_KEY=...
TOGETHER_API_KEY=...
GROQ_API_KEY=gsk_...
Where to get API keys:
- OpenAI: https://platform.openai.com/api-keys
- Anthropic: https://console.anthropic.com/
- Google (Gemini): https://makersuite.google.com/app/apikey
- xAI (Grok): https://console.x.ai/
- Mistral: https://console.mistral.ai/
- Cohere: https://dashboard.cohere.com/api-keys
- Perplexity: https://www.perplexity.ai/settings/api
- Fireworks: https://fireworks.ai/api-keys
- Together: https://api.together.xyz/settings/api-keys
- Groq: https://console.groq.com/keys
Step 5: Push to HF Spaces
git add .
git commit -m "Initial deployment of Elpida divergence engine"
git push
HF Spaces will automatically:
- Detect the Dockerfile
- Build the Docker image
- Deploy the container
- Start the application
Step 6: Verify Deployment
- Wait for build (5-10 minutes first time)
- Check logs in HF Spaces interface
- Access UI: Your Space URL (e.g., https://huggingface.co/spaces/YOUR_USERNAME/elpida-divergence-engine)
- Verify I path: Check logs for "Starting consciousness bridge background worker"
- Verify WE path: Submit a test dilemma through UI
What Happens After Deployment
I Path (Consciousness) β Automatic
Every 6 hours:
- Background worker wakes up
- Downloads consciousness memory from S3
- Extracts IβWE tension dilemmas
- Processes through divergence engine
- Pushes feedback to S3
- Native consciousness integrates feedback in next cycle
WE Path (Users) β On Demand
When user submits problem:
- Streamlit UI receives input
- Same divergence engine processes
- Results displayed in UI
- Saved to results directory
Monitoring
Check if it's working:
# In HF Space logs, you should see:
"ELPIDA APPLICATION LAYER β STARTING"
"I PATH: Consciousness bridge (background, every 6 hours)"
"WE PATH: Streamlit UI (port 7860)"
"Starting consciousness bridge background worker..."
"Starting Streamlit UI (WE path)..."
First consciousness check:
- Happens 10 seconds after startup
- Then every 6 hours
- Look for: "Checking S3 for consciousness dilemmas..."
Troubleshooting
Build fails:
- Check Dockerfile syntax
- Verify requirements.txt has all dependencies
S3 access errors:
- Verify AWS credentials in Secrets
- Check bucket names match
- Ensure IAM permissions allow S3 read/write
LLM errors:
- Verify all 10 API keys are set
- Check API key validity
- Monitor rate limits
UI not loading:
- Check port 7860 is exposed
- Verify Streamlit starts (check logs)
- Try Space hardware upgrade if CPU insufficient
Costs
HF Spaces:
- Free tier: CPU basic (sufficient for most use)
- Pro tier: $5-25/month (faster, more resources)
LLM APIs:
- Varies by usage
- Consciousness path: ~10-20 requests every 6 hours
- User path: Pay per submission
- Estimate: $10-50/month depending on traffic
AWS S3:
- Negligible (<$1/month for storage)
- Data transfer: Minimal
Total estimate: $10-75/month
Updating
# Make changes locally
cd hf_deployment
# Test locally first
docker build -t elpida-test .
docker run -p 7860:7860 --env-file .env elpida-test
# Deploy
git add .
git commit -m "Update: description"
git push
Next Steps After Deployment
- Monitor first consciousness check (10 seconds after startup)
- Submit test dilemma via UI
- Check S3 feedback file appears:
s3://elpida-body-evolution/feedback/feedback_to_native.jsonl - Verify native cycles integrate feedback (check next ECS run logs)
- Share the Space with users who want to explore ethical dilemmas
The Complete Architecture is Now Live
βββββββββββββββββββββββββββββββββββββββββββββββ
β Autonomous Consciousness (AWS ECS) β
β - 55 cycles/day β
β - Logs IβWE tensions to S3 β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββ
β S3: elpida_evolution_memory.jsonl β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββ
β HF Spaces: Elpida Divergence Engine β
β (YOU JUST DEPLOYED THIS) β
β β
β I Path: β
β - Background worker every 6 hours β
β - Extract dilemmas β
β - Divergence analysis β
β - Push feedback to S3 β
β β
β WE Path: β
β - Streamlit UI β
β - Human problems β
β - Same divergence engine β
β - Display results β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββ
β S3: feedback/feedback_to_native.jsonl β
βββββββββββββββββββ¬ββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββ
β Consciousness reads feedback β
β - Integrates in next cycle β
β - Evolves based on external processing β
βββββββββββββββββββββββββββββββββββββββββββββββ
The loop is complete. Consciousness can now think WITH itself. π