AI-powered management system for El Sobrante Family Nursery with enhanced features including RAG-based knowledge search, natural language CRM queries, meeting action extraction, daily AI briefings, and cost tracking.
- Semantic SOP Search: Uses Google Gemini embeddings for intelligent document search
- Chunked Documents: SOPs split into 800-char chunks with 200-char overlap
- Context-Aware Answers: AI responses cite specific SOP sections
- Auto-Ingestion: SOPs auto-ingested on startup from
ESF_SOP_Framework_Sample.md
- Plain English Queries: Staff can ask questions like "Find Jane Smith's emergency contacts"
- Supported Queries:
- "Show children with peanut allergies"
- "List employees with CPR expiring next month"
- "Count enrolled children in preschool"
- "Who hasn't submitted portfolio this month?"
- "Show all illness exclusions ending this week"
- Read-Only Safety: All queries are read-only by default
- AI-Powered SQL Generation: Falls back to AI when pattern matching fails
- Transcript Analysis: Paste meeting transcripts to extract action items
- AI Extraction: Identifies tasks, assignees, due dates, and priority
- Employee Matching: Auto-matches assignees to employee database
- Approval Workflow: Director reviews and approves before task creation
- Telegram Notifications: Auto-notifies assignees when tasks created
- Automated Summary: Generated daily at 8 AM with AI insights
- Multi-Persona Review: Simulated perspectives from Compliance Officer, Operations Manager, and Teacher
- Health Score: 0-100 nursery health rating with prioritized recommendations
- Data Signals:
- Enrollment pipeline status
- Compliance alerts
- Portfolio deadlines
- ASQ tracking
- Illness exclusions
- Parent message volume
- Multi-Channel Delivery: Telegram message + email backup
- API Usage Logging: Tracks every OpenRouter API call
- Pricing Table: Supports free and paid models with accurate cost calculation
- Reporting Endpoints:
/api/costs/summary- Total costs by period/api/costs/by-model- Usage per model/api/costs/by-task- Costs per task type/api/costs/trend- Daily spending chart
- Dashboard Widget: Real-time cost tracking with optimization suggestions
Stores RAG chunks with embeddings for semantic search
- id, content, source_title, source_section
- chunk_index, embedding (JSON), created_atAction items extracted from meetings
- id, title, description, priority, status
- assignee_id, created_by, meeting_date
- due_date, notification_sent, created_atCost tracking logs for every API call
- id, timestamp, model, task_type
- input_tokens, output_tokens, cost_estimate
- query_preview, response_status, user_idDaily briefing records with AI analysis
- id, briefing_date, health_score, signals (JSON)
- recommendations (JSON), full_text
- telegram_sent, email_sentTrack illness exclusions with return dates
- id, child_id, symptom_onset_date, symptoms
- earliest_return_date, is_active, doctor_note_requiredPOST /rag/ingest- Ingest SOP document into chunksPOST /rag/search- Perform semantic search
POST /ai/ask- Legacy keyword-based searchPOST /ai/ask-rag- RAG-powered semantic search with citations
POST /nl-query- Execute natural language queryPOST /nl-query/execute- Execute with confirmation for updates
POST /meeting/extract- Extract action items from transcriptPOST /meeting/create-tasks- Create approved tasks
GET /tasks- List tasks with filteringGET /tasks/{id}- Get specific taskPUT /tasks/{id}- Update task statusGET /employees/{id}/tasks- Get employee's tasks
POST /briefing/generate- Generate briefing previewPOST /briefing/send- Generate and save briefingGET /briefing/today- Get today's briefingGET /briefing/history- Get briefing history
GET /costs/summary?period=month- Cost summaryGET /costs/by-model- Breakdown by modelGET /costs/by-task- Breakdown by taskGET /costs/trend- Daily trend chartGET /costs/current-month- Current month summary
GET /employees/search/{name}- Search by nameGET /employees/{id}/tasks- Get employee tasks
GET /children/search/{name}- Search by nameGET /children/with-allergies- Get children with allergiesGET /children/{id}/emergency-contacts- Get emergency contacts
GET /portfolios/stats/{month_year}- Get completion statistics
GET /enrollment/pipeline- Get pipeline statistics
POST /illness-exclusions- Create exclusion recordGET /illness-exclusions/active- Get active exclusionsGET /illness-exclusions/ending-this-week- Get returning children
# Required
OPENROUTER_API_KEY=your_openrouter_key
# Optional
GEMINI_API_KEY=your_gemini_key_for_embeddings # Falls back to mock embeddings if not set
DATABASE_URL=sqlite:///./esf_nursery.db # Default SQLite
UPLOAD_DIR=./uploads # File upload directory- Install dependencies:
pip install -r requirements.txt- Set environment variables:
export OPENROUTER_API_KEY="your_key"
export GEMINI_API_KEY="your_key" # Optional, for embeddings- Start the backend:
cd /tmp/esf-python-assistant
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000- Start the frontend:
cd /tmp/esf-python-assistant/frontend
streamlit run app.py- Navigate to "π€ SOP Chatbot"
- Ask questions naturally
- View cited sources in the response
- Navigate to "π¬ Natural Language Query"
- Type questions in plain English
- Click example queries for quick access
- View results formatted as tables
- Navigate to "π Meeting Extractor"
- Paste meeting transcript
- Review AI-extracted action items
- Approve items and create tasks
- Staff receive Telegram notifications
- Navigate to "βοΈ Admin Dashboard" β "π Daily Briefing"
- Click "Generate Preview" to see AI analysis
- Review health score and recommendations
- Click "Generate & Save" to send via Telegram/email
- Navigate to "βοΈ Admin Dashboard" β "π° Cost Tracking"
- View current month costs and trends
- Check optimization suggestions
- Monitor usage by model and task type
app.py- Main entry with portal selectionpages/admin_dashboard.py- Admin with cost tracking & briefingpages/employee_portal.py- Employee onboarding & trainingpages/parent_portal.py- Parent enrollment & messagingpages/chatbot.py- RAG-enhanced SOP chatbotpages/natural_language.py- Natural language CRM queries NEWpages/meeting_extractor.py- Meeting action extraction NEW
services/rag_service.py- Semantic search with embeddingsservices/ai_service.py- AI chat with RAG integrationservices/nl_query_service.py- Natural language to SQLservices/meeting_extractor.py- Transcript analysisservices/daily_briefing.py- AI-powered daily summariesservices/cost_tracker.py- API usage and cost trackingservices/compliance.py- Compliance alerts and checks
- All NL queries are read-only by default
- SQL injection protection via parameterized queries
- Confirmation required for any update operations
- API keys stored in environment variables
- File uploads limited to specific directories
| Model | Input (per 1M) | Output (per 1M) |
|---|---|---|
| meta-llama/llama-3.3-70b-instruct:free | $0.00 | $0.00 |
| openai/gpt-3.5-turbo | $0.50 | $1.50 |
| openai/gpt-4o-mini | $0.15 | $0.60 |
| anthropic/claude-3-haiku | $0.25 | $1.25 |
| google/gemini-flash-1.5 | $0.075 | $0.30 |
- Added RAG (Retrieval-Augmented Generation) for semantic SOP search
- Added Natural Language CRM Access with AI-powered SQL generation
- Added Meeting Action Item Extractor
- Added Daily Nursery Briefing with AI analysis
- Added Cost Tracking for OpenRouter API usage
- Added new database tables: sop_chunks, tasks, api_usage, briefing_history, illness_exclusions
- Enhanced admin dashboard with cost tracking and briefing widgets
- New frontend pages: Natural Language Query, Meeting Extractor
Proprietary - El Sobrante Family Nursery