File size: 2,217 Bytes
c5eec51
afb3b93
c5eec51
 
 
 
 
 
 
 
0a2c5ed
c5eec51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0a2c5ed
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
---
title: Alz Multimodal Dynamic Linguistic Chatbot
emoji: πŸ“‰
colorFrom: blue
colorTo: gray
sdk: gradio
sdk_version: 5.42.0
app_file: app.py
pinned: false
license: mit
short_description: Multimodal Linguistic Chatbot for AD patients
---

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

# Alzheimer’s AI Companion (RAG + Role-Aware)

A gentle Retrieval-Augmented Generation (RAG) assistant for Alzheimer’s care contexts, with **patient** vs **caregiver** role routing, optional speech-to-text (STT) and text-to-speech (TTS), and a **Gradio** UI suitable for a Hugging Face Space.

## Features
- **Role-aware prompting**: simple, comforting tone for *patient*; concise, actionable tone for *caregiver*.
- **RAG** over your uploaded documents using FAISS + Sentence-Transformers.
- **OpenAI LLM** via `langchain_openai.ChatOpenAI`.
- **STT** using OpenAI (`gpt-4o-transcribe` or `whisper-1`), and **TTS** via `gTTS`.
- **Gradio UI** with tabs: *Chat*, *Upload Knowledge*, *Settings*.

> βš•οΈ This is **not** medical advice, nor a diagnostic tool. Always consult clinicians for health decisions.

## Quickstart (Local)
1. **Install**
   ```bash
   pip install -r requirements.txt
   ```
2. **Environment**
   ```bash
   export OPENAI_API_KEY=YOUR_KEY_HERE
   ```
3. **Run**
   ```bash
   python app.py
   ```
   Gradio will print a local URL.

## Hugging Face Space
Upload the repo (including `app.py` and `requirements.txt`) to a new **Gradio** Space. Set a **secret** named `OPENAI_API_KEY` under *Settings β†’ Variables*.

## Project Layout
```
.
β”œβ”€β”€ app.py                      # Gradio UI
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ README.md
β”œβ”€β”€ sample_data/
β”‚   └── caregiving_tips.txt     # Example doc for indexing
└── alz_companion/
    β”œβ”€β”€ agent.py                # Core RAG + role routing + audio helpers
    └── prompts.py              # System & RAG prompts
```

## Notes
- First run will download the embedding model (`sentence-transformers/all-MiniLM-L6-v2`).
- FAISS index persists in `data/faiss_index`. Delete that folder to rebuild.
- `gTTS` requires outbound Internet access to fetch the voice.

## Licence
MIT