File size: 6,994 Bytes
7ed2180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
---

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**