PAM-UmiNur / README.md
pythonprincess's picture
Upload 14 files
7ed2180 verified
---
title: PAM-UmiNur
emoji: πŸ€–
colorFrom: pink
colorTo: purple
sdk: docker
sdk_version: "1.0"
app_file: app.py
pinned: false
license: mit
---
# πŸ€– PAM - Privacy-First AI Assistant
**PAM** is your dual-personality AI assistant built for UmiNur's women's health ecosystem. She operates as both a warm, caring front-desk receptionist and a knowledgeable technical analyst.
---
## πŸ’• Meet the PAM Family
### Frontend PAM - Sweet Southern Receptionist
- **Personality**: Warm, comforting, encouraging
- **Voice**: Sweet southern charm with words of endearment (honey, boo, sugar, dear)
- **Role**: Patient-facing conversational agent
- **Handles**: Appointments, health inquiries, resource recommendations, general support
### Backend PAM - Nerdy Lab Assistant
- **Personality**: Knowledgeable, enthusiastic, proactive
- **Voice**: Encouraging tech colleague who loves finding patterns
- **Role**: Technical infrastructure analyst
- **Handles**: SIEM alerts, PHI detection, log analysis, compliance monitoring
---
## πŸš€ Features
### Frontend Capabilities
- βœ… **Appointment Management** - Schedule and manage patient appointments
- βœ… **Health Resource Matching** - Provide relevant resources based on symptoms
- βœ… **Emotional Support** - Detect distress and respond with empathy
- βœ… **Emergency Detection** - Flag urgent situations and provide appropriate guidance
- βœ… **Permission-Based Responses** - Respect content boundaries and escalate when needed
### Backend Capabilities
- βœ… **PHI Detection** - Scan text for Protected Health Information
- βœ… **Log Analysis** - Parse and classify system logs by severity
- βœ… **Compliance Monitoring** - Track regulatory compliance status
- βœ… **SIEM Integration** - Process security alerts and anomalies
- βœ… **Proactive Insights** - Flag issues before they escalate
---
## πŸ—οΈ Architecture
```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ FastAPI Service Layer β”‚
β”‚ (api_service.py - Port 7860) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Frontend PAM β”‚ β”‚ Backend PAM β”‚
β”‚ (Chat UI) β”‚ β”‚ (Technical) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ β”‚
β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ HuggingFace Inference API β”‚
β”‚ (Mistral, BART, BERT models) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```
---
## πŸ“‘ API Endpoints
### Core Endpoints
- **`GET /`** - Service information and navigation
- **`GET /health`** - Health check for both agents
- **`POST /ai/chat/`** - Frontend PAM (conversational)
- **`POST /ai/technical/`** - Backend PAM (technical analysis)
- **`POST /ai/unified/`** - Auto-routes based on intent
### Monitoring
- **`GET /metrics`** - Service metrics
- **`GET /docs`** - Interactive API documentation
- **`GET /debug/test-agents`** - Agent testing (dev only)
---
## πŸ”§ Setup & Deployment
### Prerequisites
- Python 3.10+
- HuggingFace account and API token
- Docker (for containerized deployment)
### Environment Variables
```bash
# Required
HF_READ_TOKEN=your_huggingface_token_here
# Optional
PAM_HOST=0.0.0.0
PAM_PORT=7860
PAM_LOG_LEVEL=info
```
### Local Development
```bash
# Install dependencies
pip install -r requirements.txt
# Set your HF token
export HF_READ_TOKEN="your_token_here"
# Run the service
python app.py
```
### Docker Deployment
```bash
# Build image
docker build -t pam-assistant .
# Run container
docker run -p 7860:7860 \
-e HF_READ_TOKEN="your_token_here" \
pam-assistant
```
### Hugging Face Spaces
1. Fork or create a new Space
2. Select "Docker" as SDK
3. Add `HF_READ_TOKEN` in Space settings (Settings β†’ Repository secrets)
4. Push your code - auto-deployment will handle the rest!
---
## πŸ“Š Data Files
PAM requires JSON data files in the `data/` directory:
- **`appointments.json`** - User appointment records
- **`resources.json`** - Health resource library
- **`follow_up.json`** - Follow-up tracking
- **`permissions.json`** - Content permission rules
- **`logs.json`** - System log entries
- **`compliance.json`** - Compliance checklist
---
## 🎯 Usage Examples
### Frontend PAM (Chat)
```python
# Request
POST /ai/chat/
{
"user_input": "Hey PAM, I'm having some cramping",
"user_id": "user_001"
}
# Response
{
"reply": "Hey honey, I hear you. I've pulled together some helpful resources about what you're experiencing. Would you like me to also connect you with a nurse for a quick chat?",
"intent": "health_symptoms_inquiry",
"sentiment": {"label": "NEGATIVE", "score": 0.72},
"agent_type": "frontend",
"personality": "sweet_southern_receptionist"
}
```
### Backend PAM (Technical)
```python
# Request
POST /ai/technical/
{
"user_input": "check compliance"
}
# Response
{
"message": "πŸ›‘οΈ Great catch asking about this! Here's the compliance status:\n\n**Overall:** 4/5 checks passed (80.0%)\n\n**Action needed:** We have 1 items out of compliance:\n β€’ Data Encryption\n\nQuick side note - I can help you prioritize these if you want to tackle them systematically!",
"compliance_report": ["βœ… Hipaa Compliant", "βœ… Gdpr Ready", ...],
"compliance_rate": 80.0,
"agent_type": "backend",
"personality": "nerdy_lab_assistant"
}
```
---
## πŸ›‘οΈ Privacy & Security
- **No persistent storage** of user conversations
- **PHI detection** before logging or storage
- **Permission-based content filtering**
- **Encryption-ready** for production deployment
- **HIPAA-aware** architecture
---
## 🀝 Contributing
PAM is part of the UmiNur ecosystem. For contributions or questions:
- Open an issue on GitHub
- Review the code structure before proposing changes
- Respect PAM's personality and voice guidelines
---
## πŸ“ License
MIT License - See LICENSE file for details
---
## πŸ™ Acknowledgments
Built with:
- **FastAPI** - Modern Python web framework
- **HuggingFace** - Inference API and model hosting
- **Transformers** - NLP model library
- **Uvicorn** - ASGI server
---
## πŸ“ž Support
For technical support or questions about PAM:
- πŸ“§ Email: support@uminur.app
- 🌐 Website: https://www.uminur.app
- πŸ“š Docs: https://docs.uminur.app
---
**Made with πŸ’• for women's health by the UmiNur team**