lapnt3 commited on
Commit
9263650
·
verified ·
1 Parent(s): eeb0f9c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +10 -212
README.md CHANGED
@@ -1,212 +1,10 @@
1
- # Healthcare AI Chatbot
2
-
3
- Trợ lý sức khỏe cá nhân thông minh sử dụng OpenAI API và Gradio.
4
-
5
- ## ✨ Key Features
6
-
7
- - 🤖 **Multi-Agent Architecture** - Specialized agents for nutrition, exercise, symptoms, mental health
8
- - 🧠 **Conversation Memory** - Remembers user data, no repeated questions
9
- - 🔄 **Agent Handoffs** - Smooth transitions between specialists
10
- - 💬 **Agent Communication** - Agents share context and collaborate
11
- - 📚 **RAG Integration** - Medical knowledge from WHO, CDC, NIMH
12
- - 🎯 **Context-Aware Routing** - Intelligent query understanding
13
-
14
- See [agents/AGENT_ARCHITECTURE.md](agents/AGENT_ARCHITECTURE.md) for detailed architecture documentation.
15
-
16
- ## Setup
17
-
18
- ### 1. Create Virtual Environment
19
-
20
- First, create a virtual environment to isolate project dependencies:
21
-
22
- **macOS/Linux:**
23
- ```bash
24
- python3 -m venv venv
25
- ```
26
-
27
- **Windows:**
28
- ```bash
29
- python -m venv venv
30
- ```
31
-
32
- ### 2. Activate Virtual Environment
33
-
34
- **macOS/Linux:**
35
- ```bash
36
- source venv/bin/activate
37
- ```
38
-
39
- **Windows:**
40
- ```bash
41
- venv\Scripts\activate
42
- ```
43
-
44
- ### 3. Install Dependencies
45
-
46
- ```bash
47
- pip install -r requirements.txt
48
- ```
49
-
50
- ### 4. Configure Environment Variables
51
-
52
- Create a `.env` file in the project root:
53
-
54
- ```bash
55
- OPENAI_API_KEY=your_api_key_here
56
- ```
57
-
58
- ### 5. Setup RAG System & Fine-tuning (One-time)
59
-
60
- **IMPORTANT:** Before running the app, setup the complete system with one command:
61
-
62
- ```bash
63
- # One command to setup everything (15-20 minutes)
64
- bash scripts/setup_rag.sh
65
- ```
66
-
67
- **What this does:**
68
-
69
- **Phase 1: RAG Databases (10-15 minutes)**
70
- - ✅ Downloads and processes medical datasets from HuggingFace
71
- - ✅ Builds ChromaDB vector databases for each domain
72
- - ✅ Total: ~160 MB, 6 specialized databases
73
-
74
- **Datasets by Domain:**
75
- - **Symptoms/Diseases**: ViMedical_Disease (603 diseases, ~50 MB)
76
- - **Mental Health**: MentalChat16K (16K conversations, 33 topics, ~80 MB)
77
- - **Nutrition**: LLM_Dietary_Recommendation (50 patient profiles + diet plans, ~20 MB)
78
- - **Vietnamese Food**: Vietnamese_Nutrition (73 foods with nutrition facts, ~5 MB)
79
- - **Fitness**: GYM-Exercise (1.66K exercises, ~10 MB)
80
- - **Medical Q&A**: Vietnamese_Medical_QA (9.3K Q&A pairs, ~15 MB)
81
-
82
- **Phase 2: Training Data Generation (2-3 minutes)**
83
- - ✅ Generates 200 synthetic conversations using GPT-4o-mini
84
- - ✅ 50 scenarios per agent (nutrition, symptom, exercise, mental_health)
85
- - ✅ Cost: ~$0.50 from your API budget
86
- - ✅ Saved to `fine_tuning/training_data/` (NOT committed to git)
87
-
88
- **Phase 3: Fine-tuning (Optional, 30-60 minutes)**
89
- - ❓ Prompts: "Do you want to fine-tune now? (y/N)" (10 sec timeout)
90
- - ✅ If yes: Uploads data, creates fine-tuning jobs, waits for completion
91
- - ✅ If no: Skip, you can fine-tune later with `python scripts/auto_finetune.py`
92
- - ✅ Cost: ~$2.00 from your API budget
93
- - ✅ Creates `config/fine_tuned_models.py` (NOT committed to git)
94
-
95
- **Total Cost:** ~$2.50 from your API budget (if you choose to fine-tune)
96
-
97
- **Fine-tune Later (Optional):**
98
- ```bash
99
- # If you skipped fine-tuning during setup
100
- python scripts/auto_finetune.py
101
- ```
102
-
103
- **Manual Setup (Alternative):**
104
- ```bash
105
- # RAG only (no training data generation)
106
- python data_mining/mining_vimedical.py
107
- python data_mining/mining_mentalchat.py
108
- # ... other mining scripts
109
-
110
- # Training data only
111
- python scripts/generate_training_data.py
112
-
113
- # Fine-tuning only
114
- python scripts/auto_finetune.py
115
- ```
116
-
117
- **Team Sharing:**
118
- - ✅ Each team member runs `bash scripts/setup_rag.sh` once
119
- - ✅ Everyone generates their own data with their API key
120
- - ❌ RAG databases and training data are NOT committed to git (too large)
121
- - ✅ Scripts and code are committed for easy sharing
122
-
123
- ## Run the Application
124
-
125
- You have multiple options to run the application:
126
-
127
- **Option 1: Using the shell script (recommended):**
128
- ```bash
129
- bash run.sh
130
- ```
131
-
132
- **Option 2: Using Gradio CLI:**
133
- ```bash
134
- gradio app.py
135
- ```
136
-
137
- **Option 3: Using Python directly:**
138
- ```bash
139
- python app.py
140
- ```
141
-
142
- **Notes:**
143
- - The app will launch with a local URL and a public shareable link
144
- - Ensure your virtual environment is activated before running
145
- - Make sure `OPENAI_API_KEY` is set in your `.env` file
146
-
147
- ### 5. Deactivate Virtual Environment (when done)
148
-
149
- ```bash
150
- deactivate
151
- ```
152
-
153
- ## Project Structure
154
-
155
- ```
156
- healthcare_bot/
157
- ├── app.py # File chính (Gradio UI)
158
- ├── rag/
159
- │ ├── ingest.py # Ingest tài liệu vào ChromaDB
160
- │ ├── query_engine.py # LangChain Retrieval QA
161
- │ └── data/ # Nguồn PDF/CSV/MD
162
- ├── modules/
163
- │ ├── nutrition.py # Module dinh dưỡng
164
- │ ├── exercise.py # Module bài tập
165
- │ └── rules.json # Quy tắc cơ bản
166
- ├── utils/
167
- │ └── helpers.py # Hàm hỗ trợ, tính BMI, format output
168
- ├── config/
169
- │ └── settings.py # Config env + API + model
170
- └── requirements.txt
171
- ```
172
-
173
- ## Technologies
174
-
175
- - Python 3.9+
176
- - OpenAI API (GPT-4o-mini)
177
- - Gradio 5.49.0
178
- - python-dotenv 1.1.1
179
- - Virtual Environment (venv)
180
-
181
- ## Features
182
-
183
- - 💬 **Chat interface với AI** - Giao diện trò chuyện thân thiện
184
- - 🏥 **Tư vấn sức khỏe toàn diện** - Hỏi kỹ thông tin trước khi tư vấn
185
- - 🔍 **Thu thập thông tin chi tiết** - Hỏi về triệu chứng, bệnh nền, thuốc đang dùng
186
- - 📊 **Đánh giá tổng quan** - Phân tích dựa trên nhiều yếu tố sức khỏe
187
- - 🌐 **Public shareable link** - Chia sẻ dễ dàng
188
- - 📱 **Responsive UI** - Giao diện đẹp, hiện đại
189
- - 💾 **Lưu lịch sử hội thoại** - Nhớ ngữ cảnh cuộc trò chuyện
190
-
191
- ## Cách chatbot hoạt động
192
-
193
- Khi bạn chia sẻ triệu chứng hoặc thông tin sức khỏe, chatbot sẽ:
194
-
195
- 1. **Hỏi thông tin cá nhân**: Tuổi, giới tính, cân nặng, chiều cao (nếu cần)
196
- 2. **Hỏi về triệu chứng**: Thời gian, mức độ nghiêm trọng, triệu chứng kèm theo
197
- 3. **Hỏi về bệnh nền**: Tiểu đường, huyết áp cao, tim mạch, v.v.
198
- 4. **Hỏi về thuốc**: Thuốc đang dùng, liệu pháp điều trị
199
- 5. **Hỏi về lối sống**: Chế độ ăn, tập luyện, giấc ngủ, stress
200
- 6. **Đưa ra tư vấn**: Sau khi có đủ thông tin, đưa ra lời khuyên toàn diện và chính xác
201
-
202
- **Ví dụ:**
203
- ```
204
- User: "Tôi bị đau đầu"
205
- Bot: "Tôi hiểu bạn đang bị đau đầu. Để tư vấn chính xác hơn, cho tôi hỏi thêm:
206
- - Bạn bao nhiêu tuổi?
207
- - Đau đầu kéo dài bao lâu rồi?
208
- - Mức độ đau (nhẹ/vừa/nặng)?
209
- - Có triệu chứng kèm theo không (buồn nôn, chóng mặt)?
210
- - Bạn có bệnh nền gì không?
211
- - Đang dùng thuốc gì không?"
212
- ```
 
1
+ ---
2
+ title: My Gradio App
3
+ emoji: 😎
4
+ colorFrom: indigo
5
+ colorTo: purple
6
+ sdk: gradio
7
+ sdk_version: "4.37.2"
8
+ app_file: app.py
9
+ pinned: false
10
+ ---