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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
🚀 Deploying AgenticAI Academy to Hugging Face Spaces
|
| 2 |
+
This guide will walk you through deploying the AgenticAI Academy platform to Hugging Face Spaces.
|
| 3 |
+
|
| 4 |
+
📋 Prerequisites
|
| 5 |
+
A Hugging Face account
|
| 6 |
+
Git installed on your computer
|
| 7 |
+
Basic familiarity with command line
|
| 8 |
+
🛠️ Step-by-Step Deployment
|
| 9 |
+
Step 1: Create a New Space
|
| 10 |
+
Go to Hugging Face Spaces
|
| 11 |
+
Click "Create new Space"
|
| 12 |
+
Configure your Space:
|
| 13 |
+
Space name: AgenticAI-Academy (or your preferred name)
|
| 14 |
+
Select SDK: Gradio
|
| 15 |
+
SDK Version: 4.19.2
|
| 16 |
+
Space visibility: Public
|
| 17 |
+
License: MIT
|
| 18 |
+
Click "Create Space"
|
| 19 |
+
Step 2: Clone the Space Repository
|
| 20 |
+
bash
|
| 21 |
+
# Clone your new Space
|
| 22 |
+
git clone https://huggingface.co/spaces/YOUR_USERNAME/AgenticAI-Academy
|
| 23 |
+
cd AgenticAI-Academy
|
| 24 |
+
Step 3: Add the Application Files
|
| 25 |
+
Copy all the files from this package:
|
| 26 |
+
|
| 27 |
+
bash
|
| 28 |
+
# Copy the main application
|
| 29 |
+
cp app.py ./
|
| 30 |
+
|
| 31 |
+
# Copy requirements
|
| 32 |
+
cp requirements.txt ./
|
| 33 |
+
|
| 34 |
+
# Copy README for Space card
|
| 35 |
+
cp README.md ./
|
| 36 |
+
|
| 37 |
+
# Copy other configuration files
|
| 38 |
+
cp .env.example .env
|
| 39 |
+
cp .gitignore ./
|
| 40 |
+
cp Dockerfile ./
|
| 41 |
+
Step 4: Configure Environment Variables (Optional)
|
| 42 |
+
If you want to enable full functionality with real AI models:
|
| 43 |
+
|
| 44 |
+
Go to your Space settings
|
| 45 |
+
Click on "Settings" tab
|
| 46 |
+
Scroll to "Repository secrets"
|
| 47 |
+
Add your API keys:
|
| 48 |
+
OPENAI_API_KEY
|
| 49 |
+
ANTHROPIC_API_KEY
|
| 50 |
+
GOOGLE_AI_API_KEY
|
| 51 |
+
Step 5: Commit and Push
|
| 52 |
+
bash
|
| 53 |
+
# Add all files
|
| 54 |
+
git add .
|
| 55 |
+
|
| 56 |
+
# Commit
|
| 57 |
+
git commit -m "Initial deployment of AgenticAI Academy"
|
| 58 |
+
|
| 59 |
+
# Push to Hugging Face
|
| 60 |
+
git push origin main
|
| 61 |
+
Step 6: Monitor Deployment
|
| 62 |
+
Go to your Space URL: https://huggingface.co/spaces/YOUR_USERNAME/AgenticAI-Academy
|
| 63 |
+
Watch the build logs
|
| 64 |
+
Once deployed, your app will be live!
|
| 65 |
+
🎨 Customization Options
|
| 66 |
+
Update Space Metadata
|
| 67 |
+
Edit the top of README.md to customize:
|
| 68 |
+
|
| 69 |
+
yaml
|
| 70 |
+
---
|
| 71 |
+
title: Your Custom Title
|
| 72 |
+
emoji: 🎓
|
| 73 |
+
colorFrom: purple
|
| 74 |
+
colorTo: blue
|
| 75 |
+
sdk: gradio
|
| 76 |
+
sdk_version: 4.19.2
|
| 77 |
+
app_file: app.py
|
| 78 |
+
pinned: true
|
| 79 |
+
license: mit
|
| 80 |
+
---
|
| 81 |
+
Modify Theme
|
| 82 |
+
In app.py, change the theme:
|
| 83 |
+
|
| 84 |
+
python
|
| 85 |
+
# Light theme
|
| 86 |
+
theme=gr.themes.Base()
|
| 87 |
+
|
| 88 |
+
# Dark theme
|
| 89 |
+
theme=gr.themes.Base(
|
| 90 |
+
primary_hue="purple",
|
| 91 |
+
secondary_hue="blue",
|
| 92 |
+
neutral_hue="gray",
|
| 93 |
+
text_size="lg"
|
| 94 |
+
)
|
| 95 |
+
Add Custom Branding
|
| 96 |
+
Replace the header in app.py:
|
| 97 |
+
|
| 98 |
+
python
|
| 99 |
+
def create_header():
|
| 100 |
+
return """
|
| 101 |
+
<div style="text-align: center;">
|
| 102 |
+
<img src="YOUR_LOGO_URL" width="200">
|
| 103 |
+
<h1>Your Academy Name</h1>
|
| 104 |
+
</div>
|
| 105 |
+
"""
|
| 106 |
+
🔧 Advanced Configuration
|
| 107 |
+
Enable Persistent Storage
|
| 108 |
+
For production use with user data persistence:
|
| 109 |
+
|
| 110 |
+
Add a database service:
|
| 111 |
+
python
|
| 112 |
+
# In app.py
|
| 113 |
+
import sqlite3
|
| 114 |
+
|
| 115 |
+
def init_database():
|
| 116 |
+
conn = sqlite3.connect('agenticai.db')
|
| 117 |
+
# Create tables
|
| 118 |
+
conn.execute('''CREATE TABLE IF NOT EXISTS users ...''')
|
| 119 |
+
Use Hugging Face Datasets for storage:
|
| 120 |
+
python
|
| 121 |
+
from huggingface_hub import HfApi
|
| 122 |
+
|
| 123 |
+
api = HfApi()
|
| 124 |
+
# Save user progress
|
| 125 |
+
api.upload_file(...)
|
| 126 |
+
Add Real AI Integration
|
| 127 |
+
To connect real AI models:
|
| 128 |
+
|
| 129 |
+
python
|
| 130 |
+
# In app.py
|
| 131 |
+
import openai
|
| 132 |
+
from anthropic import Anthropic
|
| 133 |
+
|
| 134 |
+
# Initialize clients
|
| 135 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 136 |
+
anthropic = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))
|
| 137 |
+
|
| 138 |
+
# Use in agent generation
|
| 139 |
+
def generate_real_response(prompt, model="gpt-4"):
|
| 140 |
+
response = openai.chat.completions.create(
|
| 141 |
+
model=model,
|
| 142 |
+
messages=[{"role": "user", "content": prompt}]
|
| 143 |
+
)
|
| 144 |
+
return response.choices[0].message.content
|
| 145 |
+
Enable Analytics
|
| 146 |
+
Add tracking to understand usage:
|
| 147 |
+
|
| 148 |
+
python
|
| 149 |
+
# Simple analytics
|
| 150 |
+
def track_event(event_name, user_email=None):
|
| 151 |
+
timestamp = datetime.now().isoformat()
|
| 152 |
+
# Log to file or external service
|
| 153 |
+
with open('analytics.log', 'a') as f:
|
| 154 |
+
f.write(f"{timestamp},{event_name},{user_email}\n")
|
| 155 |
+
🚦 Deployment Checklist
|
| 156 |
+
Space created on Hugging Face
|
| 157 |
+
All files uploaded
|
| 158 |
+
README.md configured with metadata
|
| 159 |
+
Environment variables set (if needed)
|
| 160 |
+
Space is building successfully
|
| 161 |
+
Application loads without errors
|
| 162 |
+
All tabs/features working
|
| 163 |
+
Mobile responsive (test on phone)
|
| 164 |
+
🐛 Common Issues & Solutions
|
| 165 |
+
Build Fails
|
| 166 |
+
Issue: "No module named 'gradio'" Solution: Check requirements.txt is properly formatted
|
| 167 |
+
|
| 168 |
+
App Crashes on Load
|
| 169 |
+
Issue: Memory error Solution: Reduce model loading or use smaller models
|
| 170 |
+
|
| 171 |
+
Slow Performance
|
| 172 |
+
Issue: Long response times Solution:
|
| 173 |
+
|
| 174 |
+
Use async functions
|
| 175 |
+
Cache common responses
|
| 176 |
+
Optimize data processing
|
| 177 |
+
📊 Monitoring Your Space
|
| 178 |
+
View Analytics
|
| 179 |
+
Go to Space settings
|
| 180 |
+
Check "Analytics" tab for:
|
| 181 |
+
Daily/monthly visits
|
| 182 |
+
User engagement
|
| 183 |
+
Error logs
|
| 184 |
+
Enable Discussions
|
| 185 |
+
Allow users to provide feedback:
|
| 186 |
+
|
| 187 |
+
Settings → Features
|
| 188 |
+
Enable "Discussions"
|
| 189 |
+
🔄 Updating Your Space
|
| 190 |
+
To update after deployment:
|
| 191 |
+
|
| 192 |
+
bash
|
| 193 |
+
# Make changes locally
|
| 194 |
+
edit app.py
|
| 195 |
+
|
| 196 |
+
# Commit and push
|
| 197 |
+
git add .
|
| 198 |
+
git commit -m "Update: Added new feature"
|
| 199 |
+
git push origin main
|
| 200 |
+
The Space will automatically rebuild!
|
| 201 |
+
|
| 202 |
+
🌟 Making it Featured
|
| 203 |
+
To get your Space featured:
|
| 204 |
+
|
| 205 |
+
Ensure high quality and originality
|
| 206 |
+
Add good documentation
|
| 207 |
+
Make it interactive and engaging
|
| 208 |
+
Share on social media with #HuggingFace
|
| 209 |
+
Engage with the community
|
| 210 |
+
🤝 Getting Help
|
| 211 |
+
Hugging Face Forums: https://discuss.huggingface.co/
|
| 212 |
+
Discord: https://discord.gg/huggingface
|
| 213 |
+
Documentation: https://huggingface.co/docs/hub/spaces
|
| 214 |
+
🎉 Congratulations!
|
| 215 |
+
Your AgenticAI Academy is now live on Hugging Face Spaces! Share your Space URL and start building the AI education community.
|
| 216 |
+
|
| 217 |
+
Your Space URL: https://huggingface.co/spaces/YOUR_USERNAME/AgenticAI-Academy
|
| 218 |
+
|
| 219 |
+
Remember to:
|
| 220 |
+
|
| 221 |
+
Share on social media
|
| 222 |
+
Add to your portfolio
|
| 223 |
+
Collect user feedback
|
| 224 |
+
Iterate and improve
|
| 225 |
+
Happy teaching! 🚀
|
| 226 |
+
|