Spaces:
Sleeping
Sleeping
File size: 5,541 Bytes
b7f3196 |
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 |
# π Quick Start Guide - Medical Q&A Bot Web UI
This guide will help you get the web interface up and running quickly!
## Prerequisites
- Python 3.8 or higher
- Git (already done since you have the repo)
- Virtual environment (recommended)
## Step-by-Step Setup
### 1οΈβ£ Navigate to the Project Directory
```powershell
cd "c:\Users\Tarak Jha\OneDrive - Coast to Coast Logistics\Desktop\HEALTHBOT\health-query-classifier"
```
### 2οΈβ£ Create and Activate Virtual Environment (Recommended)
```powershell
# Create virtual environment
python -m venv .venv
# Activate it (Windows PowerShell)
.venv\Scripts\Activate.ps1
# If you get an execution policy error, run this first:
# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
```
### 3οΈβ£ Install Dependencies
```powershell
pip install -r requirements.txt
```
This will install:
- All existing dependencies (PyTorch, sentence-transformers, etc.)
- **Gradio** - For the web UI (recommended)
- **Streamlit** - Alternative web UI framework
### 4οΈβ£ Prepare Data (If Not Already Done)
```powershell
python -m adapters.build_corpora
```
This creates the necessary corpus files from PubMed and Miriad databases.
### 5οΈβ£ Launch the Web UI
**Option A: Gradio (Recommended)**
```powershell
python app.py
```
Then open: http://127.0.0.1:7860
**Option B: Streamlit (Alternative)**
```powershell
streamlit run app_streamlit.py
```
Then open: http://localhost:8501
## π― Choose Your UI
### Gradio (`app.py`)
β
Clean, modern interface
β
Dual-view (Formatted HTML + JSON)
β
Easy to share (can create public links)
β
Automatic API generation
β
Great for ML demos
### Streamlit (`app_streamlit.py`)
β
More interactive and customizable
β
Sidebar with settings
β
Real-time updates
β
Better for data science apps
β
More widgets and components
**We recommend starting with Gradio!** It's simpler and looks very professional.
## π§ͺ Test with Example Queries
Try these queries to see the system in action:
1. **Medical Query:**
> "I'm having a really bad rash on my hands. I'm pretty sure it's my eczema flaring up. Is there anything stronger than aquaphor I can use on it?"
2. **Medical Emergency:**
> "worst headache of my life with fever and stiff neck"
3. **Vaccine Question:**
> "I'm traveling to South America soon. Do I need to get any vaccines before I go?"
4. **Administrative Query:**
> "Hey is there any way I can get an appointment in the next month?"
## π¨ UI Features
### Classification
- Shows whether query is medical, administrative, or other
- Displays confidence scores for each category
- Visual progress bars or charts
### Document Retrieval (Medical Queries Only)
- Retrieves top N relevant documents
- Shows BM25, Dense, and RRF scores
- Displays document title, text preview, and metadata
- Toggle between formatted view and raw JSON
### Settings
- **Number of Results:** 1-50 documents
- **Use Reranker:** Enable for better accuracy (slower)
## π§ Troubleshooting
### "No module named 'gradio'"
```powershell
pip install gradio
```
### "No corpora files found"
```powershell
python -m adapters.build_corpora
```
### Port Already in Use
Edit `app.py` and change the port:
```python
demo.launch(server_port=8080) # Change 7860 to 8080
```
### Models Not Loading
Make sure you have your HuggingFace token configured in `env.list`:
```
HF_TOKEN="your-huggingface-token"
```
## π Advanced Options
### Share Publicly (Gradio)
Edit `app.py`, line ~255:
```python
demo.launch(share=True) # Creates a 72-hour public link
```
### Add Authentication (Gradio)
```python
demo.launch(auth=("username", "password"))
```
### Change Theme (Streamlit)
Create `.streamlit/config.toml`:
```toml
[theme]
primaryColor = "#667eea"
backgroundColor = "#ffffff"
secondaryBackgroundColor = "#f0f2f6"
```
## π± Accessing from Other Devices
To access from other devices on your network:
1. Find your IP address:
```powershell
ipconfig
```
Look for "IPv4 Address" (e.g., 192.168.1.100)
2. Edit `app.py`:
```python
demo.launch(server_name="0.0.0.0", server_port=7860)
```
3. Access from other device:
```
http://192.168.1.100:7860
```
## π For Your Group Presentation
### Demo Tips:
1. Start with the interface loaded beforehand
2. Have example queries ready
3. Show both medical and administrative classification
4. Demonstrate the reranker toggle
5. Show both formatted and JSON views
6. Explain the confidence scores
### Screenshots to Take:
- Main interface
- Classification results
- Document retrieval results
- Settings panel
- Example queries
### Key Points to Mention:
- Built with modern Python web frameworks
- Real-time classification and retrieval
- Hybrid search (BM25 + Dense embeddings)
- Optional reranking for accuracy
- Clean, professional interface
## π Next Steps
Once you're comfortable with the UI, you can:
- Customize the styling (CSS in `app.py`)
- Add more example queries
- Integrate with other systems via the API
- Deploy to cloud (Hugging Face Spaces, AWS, etc.)
## π€ Team Credits
Display proudly on the interface:
- David Gray
- Tarak Jha
- Sravani Segireddy
- Riley Millikan
- Kent R. Spillner
---
**Need help?** Check the full documentation in `UI_README.md` or ask your team members!
|