Spaces:
Sleeping
Sleeping
A newer version of the Streamlit SDK is available: 1.57.0
Quick Start Guide for HuggingFace Deployment
This is a 5-minute quick start to get your production-ready chatbot deployed.
π Step 1: Deploy to HuggingFace (2 minutes)
If your Space is already set up:
Upload these files to your HuggingFace Space:
app.py(updated)config.py(new)requirements.txt(updated)utils/directory (all files)
Your Space will automatically restart and install new dependencies
If you need to create a new Space:
- Go to https://huggingface.co/spaces
- Click "Create new Space"
- Choose "Streamlit" as SDK
- Upload all files from
outreach/pipelines/gemini_file_search/
π Step 2: Set Environment Variables (1 minute)
- Go to your Space Settings β Variables and secrets
- Add these secrets:
| Name | Value | Required? |
|---|---|---|
GEMINI_API_KEY |
Your Google Gemini API key | β Yes |
NTFY_TOPIC |
Your random topic name (e.g., hickeylab-x9k2m7) |
β Recommended |
Finding your Gemini API key:
- Go to https://aistudio.google.com/app/apikey
- Create or copy your API key
π± Step 3: Set Up Notifications (2 minutes) - Optional but Recommended
Choose your method:
Option A: Mobile App (Best)
- Install ntfy app from App Store or Google Play
- Open app and tap "Subscribe to topic"
- Enter your topic name (e.g.,
hickeylab-x9k2m7) - Done! You'll get instant push notifications
Option B: Browser
- Go to
https://ntfy.sh/your-topic-name - Click "Subscribe" button
- Allow browser notifications
- Done! You'll get browser notifications
Test it:
curl -d "Hello from Hickey Lab!" ntfy.sh/your-topic-name
You should get a notification immediately!
β Step 4: Test Your Chatbot (2 minutes)
- Open your HuggingFace Space
- Wait for it to start (first start takes ~30 seconds)
- Ask a test question: "What does the Hickey Lab research?"
- Verify you get a response
- Check sidebar for "π Show Usage Stats" to see it logged
π You're Done!
Your chatbot now has:
- β Cost tracking and budget protection
- β Rate limiting to prevent abuse
- β Security validation
- β Push notifications (if you set up ntfy.sh)
- β Better responses with conversation context
ποΈ Customization (Optional)
To change limits:
Edit config.py in your Space:
# Cost limits
MONTHLY_BUDGET_USD = 50.0 # Change to your budget
DAILY_QUERY_LIMIT = 200 # Change to your preference
# Rate limits
RATE_LIMIT_PER_HOUR = 20 # Queries per hour
RATE_LIMIT_PER_DAY = 200 # Queries per day
# Suggested questions
SUGGESTED_QUESTIONS = [
"Your custom question 1",
"Your custom question 2",
# ... add your own
]
Save the file and your Space will restart with new settings.
π Monitoring Your Usage
Quick check:
- Open your chatbot
- Click "π Show Usage Stats" in sidebar
- See today's queries and cost
Get alerts:
- If you set up ntfy.sh, you'll automatically get notified when:
- Someone hits rate limits
- Daily cost exceeds $5
- Monthly budget is approaching
- Suspicious activity detected
β οΈ Troubleshooting
"GEMINI_API_KEY not found"
- Go to Space Settings β Variables and secrets
- Make sure
GEMINI_API_KEYis added as a Secret (not a variable)
"File Search store not found"
- Your knowledge base needs to be set up first
- Check that
hickey-lab-knowledge-baseexists in your Gemini project
Notifications not working
- Check you subscribed to the correct topic name
- Try sending a test:
curl -d "test" ntfy.sh/your-topic-name - Make sure
NTFY_TOPICis set in HuggingFace secrets
Space keeps restarting
- Check Space logs for errors
- Make sure all files are uploaded correctly
- Verify
requirements.txtis present
π More Information
- Detailed technical guide: See
IMPLEMENTATION_GUIDE.md - Feature explanations: See
FEATURE_SUMMARY.md - Test modules: Run
python test_setup.pylocally
π Need Help?
- Check the logs in your HuggingFace Space
- Review
IMPLEMENTATION_GUIDE.mdfor detailed instructions - Make sure all files were uploaded correctly
- Verify environment variables are set
That's it! Your production-ready chatbot is live. π
The implementation handles:
- π° Cost protection
- π‘οΈ Security
- π Monitoring
- π Alerts
- π¬ Better conversations
Enjoy your production-ready AI assistant!