Spaces:
Sleeping
A newer version of the Streamlit SDK is available: 1.56.0
title: Hickey Lab AI Assistant
emoji: π§¬
colorFrom: blue
colorTo: purple
sdk: streamlit
sdk_version: 1.52.1
app_file: app.py
pinned: false
Hickey Lab AI Assistant - Production Ready β¨
A production-ready Streamlit chatbot powered by Google Gemini 2.5 Flash and the File Search API.
π― Features
- β Cost Management - Tracks usage and enforces budget limits
- β Rate Limiting - Prevents abuse (20 queries/hour per user)
- β Security - Input validation and prompt injection protection
- β Push Notifications - Get alerted about important events (via ntfy.sh)
- β Conversation Context - Remembers previous messages for better responses
- β Mobile Friendly - Responsive design for all devices
- β Usage Statistics - Real-time monitoring in sidebar
π Quick Start (5 minutes)
See QUICK_START.md for deployment instructions.
TL;DR:
- Upload files to HuggingFace Space
- Set
GEMINI_API_KEYsecret - (Optional) Set
NTFY_TOPICfor notifications - Done!
π Documentation
| Document | Description |
|---|---|
| QUICK_START.md | 5-minute deployment guide |
| FEATURE_SUMMARY.md | What each tool does (for non-technical users) |
| IMPLEMENTATION_GUIDE.md | Detailed technical documentation |
π§ͺ Testing
Run the setup test to verify everything works:
python test_setup.py
This tests all modules and configurations.
π Project Structure
gemini_file_search/
βββ app.py # Main Streamlit app (enhanced)
βββ config.py # Configuration settings
βββ requirements.txt # Python dependencies
βββ test_setup.py # Setup verification script
βββ utils/ # Utility modules
β βββ __init__.py
β βββ cost_tracker.py # Cost management
β βββ rate_limiter.py # Rate limiting
β βββ security.py # Security validation
β βββ alerts.py # Push notifications (ntfy.sh)
βββ docs/
βββ QUICK_START.md # Quick deployment guide
βββ FEATURE_SUMMARY.md # What each feature does
βββ IMPLEMENTATION_GUIDE.md # Technical details
βοΈ Configuration
Edit config.py to customize:
# Cost limits
MONTHLY_BUDGET_USD = 50.0
DAILY_QUERY_LIMIT = 200
# Rate limits
RATE_LIMIT_PER_HOUR = 20
RATE_LIMIT_PER_DAY = 200
# Suggested questions
SUGGESTED_QUESTIONS = [...]
# And more...
π Environment Variables
| Variable | Required | Description |
|---|---|---|
GEMINI_API_KEY |
β Yes | Your Google AI API key from aistudio.google.com |
NTFY_TOPIC |
β Recommended | Your ntfy.sh topic for push notifications |
π Monitoring
In the App:
- Check "π Show Usage Stats" in sidebar
- See today's query count and cost
- View monthly totals
Push Notifications (if enabled):
- Rate limit violations
- Cost threshold alerts
- Security warnings
- Budget exceeded alerts
π Troubleshooting
App won't start:
- Check logs in HuggingFace Space
- Verify
GEMINI_API_KEYis set as a Secret - Make sure all files are uploaded
Notifications not working:
- Check
NTFY_TOPICis set - Test with:
curl -d "test" ntfy.sh/your-topic - Verify you're subscribed to the correct topic
Rate limit too strict:
- Edit
RATE_LIMIT_PER_HOURinconfig.py - Default is 20 queries/hour
See IMPLEMENTATION_GUIDE.md for more troubleshooting.
π‘ What's New
This is an upgraded version with production features:
- Cost tracking prevents surprise bills
- Rate limiting prevents abuse
- Security validation blocks attacks
- Push notifications keep you informed
- Conversation context improves responses
See FEATURE_SUMMARY.md for detailed explanations.
π Embedding in Google Sites
Once deployed, you'll get a public URL. To add to Google Sites:
Simple Link (Always works):
- Add a button: "Chat with our AI Assistant β"
- Link to your HuggingFace Space URL
Embed (HuggingFace Spaces):
- In Google Sites: Insert β Embed β By URL
- Paste your Space URL
- Adjust size as needed
π Cost Estimates
Based on Gemini 2.5 Flash pricing:
- ~$0.0003 per query (average)
- 100 queries = $0.03
- 1,000 queries = $0.30
- 10,000 queries = $3.00
Default monthly cap: $50 (adjustable in config)
π€ Support
For issues or questions:
- Check the documentation files
- Review HuggingFace Space logs
- Run
python test_setup.pyto verify setup - Check that environment variables are set correctly
Production ready and deployed in minutes! π