Spaces:
Sleeping
Download README.md from bnewcomer/MediBot: direct link, hf CLI and curl.
- Browser
- Download file 4.45 kB
-
https://huggingface.co/spaces/bnewcomer/MediBot/resolve/main/README.md
- Command line
-
hf download hf://spaces/bnewcomer/MediBot/README.md
-
curl -L -o README.md https://huggingface.co/spaces/bnewcomer/MediBot/resolve/main/README.md
A newer version of the Gradio SDK is available: 6.32.0
title: MediBot
emoji: 🩺
colorFrom: yellow
colorTo: blue
sdk: gradio
sdk_version: 6.6.0
python_version: '3.12'
app_file: app.py
pinned: false
license: mit
short_description: Medical symptom exploration tool
MediBot
Educational symptom exploration with Gradio, OpenAI, FAISS, and a lightweight ranking pipeline.
Not a medical device. For educational use only. Do not use this app to rule out emergencies or replace a licensed clinician.
Overview
MediBot accepts symptom questions in plain language and can:
- extract structured symptom context from user text
- ask follow-up questions when the symptom signal is too weak or ambiguous
- estimate urgency for recognized symptoms
- rank possible conditions for educational review
- explain named conditions and list precautions
- add travel-aware handling for rare tropical diseases
The app is built around a small multi-step workflow in app.py:
ReActRouterbuilds a short plan for each turnClarificationAgentdecides whether follow-up questions are neededSymptomSeverityAgentscores urgency and handles red-flag escalationDiseaseDiagnosisAgentmaps symptoms, retrieves FAISS candidates, and scores them- description and precaution agents answer disease-specific questions
Repository Layout
MediBot/
|-- app.py
|-- data/
|-- diagnosis_engine/
|-- eval/
|-- scripts/
|-- static/
|-- tests/
`-- requirements.txt
Key directories:
data/: CSV datasets used by the appdiagnosis_engine/: FAISS retrieval, scoring, reranking, prevalence priors, and vocabulary mappingeval/: deterministic real-query evaluation cases and runnerscripts/: lightweight local checks such assmoke_check.pytests/: pytest coverage for helpers, chat flow, and realistic symptom queries
Local Setup
- Create and activate a virtual environment.
- Install runtime dependencies from
requirements.txt. - Install
requirements-dev.txtas well if you want to run tests locally. - Set
OPENAI_API_KEYin your environment or a local.envfile. - Run the smoke check before launching the app.
Example:
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
pip install -r requirements-dev.txt
python scripts/smoke_check.py
python app.py
If you use make, the repo also includes MakeFile.mak with helper targets for setup, tests, and deployment checks.
Testing
Quick checks:
python scripts/smoke_check.py
python scripts/evaluate_real_queries.py
Pytest:
.venv\Scripts\python.exe -m pytest tests -q
Make targets:
make -f MakeFile.mak smoke-check
make -f MakeFile.mak eval
make -f MakeFile.mak test
make -f MakeFile.mak deploy-check
The real-query evaluation uses natural-language prompts from eval/real_symptom_queries.json and runs them through a deterministic fallback path so results stay stable across test runs.
Hugging Face Deployment
Before deploying to Hugging Face Spaces:
- set
OPENAI_API_KEYas a Space Secret - run
python scripts/smoke_check.py - optionally run
python scripts/evaluate_real_queries.py - confirm all required CSV files are present in
data/ - review logging behavior and avoid storing raw public symptom text
Do not commit or deploy local-only files:
.env.env.*logs/faiss_store/__pycache__/*.pyc
These exclusions are also tracked in .hfignore.
Optional to exclude from Spaces if you do not need them there:
tests/eval/
Notes on Ranking
The displayed "match strength" is the candidate hybrid_score. It combines:
- Jaccard overlap
- TF-IDF cosine similarity
- symptom coverage
- a rarity penalty derived from
diagnosis_engine/prevalence.py
Weak matches are expected for broad symptom sets. The app explicitly warns users when the top score is low and asks follow-up questions when evidence is too ambiguous.