Medical Q&A Bot - UI Implementation Summary
π¦ What Was Added
New Files Created:
app.py- Main Gradio web interface (RECOMMENDED)- Clean, modern UI with gradient header
- Dual-view mode (formatted HTML + JSON)
- Real-time classification and retrieval
- Example queries built-in
- Automatic API generation
app_streamlit.py- Alternative Streamlit interface- Interactive sidebar with settings
- Card-based result display
- Progress bars for confidence scores
- More customizable styling options
QUICKSTART.md- Step-by-step setup guide- Installation instructions
- How to launch both UIs
- Troubleshooting tips
- Demo tips for presentations
UI_README.md- Comprehensive documentation- Feature descriptions
- Configuration options
- Advanced usage
- API information
setup_ui.py- Automated setup script- Installs all dependencies
- Checks for required data files
- Verifies setup completeness
Modified Files:
requirements.txt- Added:gradio- Main UI frameworkstreamlit- Alternative UI framework
π― Key Features
Classification Display
- β Shows query type (Medical/Administrative/Other)
- β Confidence scores with visual indicators
- β Color-coded results
Document Retrieval
- β Retrieves top N relevant documents (1-50)
- β Shows BM25, Dense, and RRF scores
- β Displays document preview with full metadata
- β Optional reranker for better accuracy
User Experience
- β Clean, professional design
- β Example queries for easy testing
- β Formatted and raw JSON views
- β Responsive layout
- β Real-time processing
π Quick Start (TL;DR)
# 1. Install dependencies
pip install -r requirements.txt
# 2. Build data (if needed)
python -m adapters.build_corpora
# 3. Launch UI (choose one)
python app.py # Gradio (recommended)
streamlit run app_streamlit.py # Streamlit (alternative)
π Which UI to Use?
Use Gradio (app.py) if you want:
- Quick setup and deployment
- Clean, minimal interface
- Easy sharing (public links)
- Automatic REST API
- Better for demos and presentations
Use Streamlit (app_streamlit.py) if you want:
- More interactive controls
- Sidebar with settings
- More customization options
- Data-science focused interface
Recommendation: Start with Gradio - it's simpler and looks very professional!
π How It Works
User Input β Gradio/Streamlit Interface
β
Classifier (classify query as medical/admin/other)
β
If Medical β Retriever (BM25 + Dense + RRF)
β
Optional Reranker (cross-encoder)
β
Display Results (formatted cards + JSON)
π For Your Presentation
Demo Flow:
- Open the interface - Show the clean design
- Enter a medical query - e.g., "I have a rash on my hands"
- Show classification - Highlight confidence scores
- Display results - Show retrieved medical documents
- Try administrative query - Show different handling
- Toggle settings - Demonstrate reranker and result count
- Show JSON view - For technical audience
Key Talking Points:
- "We built a user-friendly web interface using Gradio"
- "The system classifies queries in real-time with confidence scores"
- "For medical queries, it retrieves relevant research from PubMed and Miriad"
- "Uses hybrid search combining BM25 and dense embeddings"
- "Optional reranker for improved accuracy"
π¨ Customization Options
Change Theme/Colors
Edit the CSS in app.py:
custom_css = """
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
"""
Add More Example Queries
Edit the examples list in app.py:
gr.Examples(
examples=[
["Your custom query here"],
],
inputs=query_input,
)
Change Port
demo.launch(server_port=8080) # Default is 7860
Enable Public Sharing
demo.launch(share=True) # Creates 72-hour public link
π§ Technical Details
Gradio Version
- Framework: Gradio 4.x
- Features: Blocks API, custom CSS, examples, tabs
- Auto-generates REST API at
/docs
Streamlit Version
- Framework: Streamlit
- Features: Sidebar, caching, progress bars, metrics
- More suitable for data exploration
Integration
- Uses existing classifier and retriever modules
- No changes to core logic
- Models loaded once and cached
- Async processing for better UX
π File Structure
health-query-classifier/
βββ app.py # β Main Gradio UI
βββ app_streamlit.py # β Alternative Streamlit UI
βββ setup_ui.py # β Setup script
βββ QUICKSTART.md # β Quick start guide
βββ UI_README.md # β Detailed documentation
βββ requirements.txt # β Updated with gradio/streamlit
βββ classifier/
β βββ infer.py # Used by UI
β βββ ...
βββ retriever/
β βββ ...
βββ team/
βββ candidates.py # Used by UI
βββ ...
π Common Issues & Solutions
"Module not found: gradio"
pip install gradio
"No corpora files found"
python -m adapters.build_corpora
Models take long to load
- This is normal on first run
- Models are cached after initial load
- Consider using smaller models for faster demo
Port already in use
- Change port in
app.py(line ~255) - Or kill the process using that port
π Deployment Options
Local (Current Setup)
- Best for development and demos
- Access via localhost
Hugging Face Spaces (Free)
- Free hosting for Gradio apps
- Easy to deploy
- Public URL
Cloud Platforms
- AWS, Google Cloud, Azure
- More control and scalability
- Requires more setup
π Future Enhancements
Potential additions for future development:
- User authentication
- Query history
- Bookmarking results
- Export to PDF
- Multi-language support
- Voice input
- Mobile app
- Analytics dashboard
π₯ Team Contributions
This UI implementation demonstrates:
- Full-stack development skills
- ML model integration
- User experience design
- Modern web frameworks
- Professional documentation
Perfect for showcasing in your group project presentation!
π Support
For issues or questions:
- Check
QUICKSTART.mdfor setup issues - Check
UI_README.mdfor feature documentation - Review error messages carefully
- Contact team members
β Ready to Present!
Your medical Q&A bot now has a professional web interface that:
- β Looks modern and clean
- β Is easy to use
- β Demonstrates your ML capabilities
- β Provides clear results
- β Is well-documented
- β Can be easily deployed
Great work, team! π
Created by: Tarak Jha, with contributions from the entire team Team: David Gray β’ Tarak Jha β’ Sravani Segireddy β’ Riley Millikan β’ Kent R. Spillner