parvv-24/CoughGPT
๐ฉบ CoughGPT
CoughGPT is an AI health analysis project that takes natural-language symptom descriptions or condition names, predicts a likely disease or medication list, and generates a plain-English medical explanation with Gemini. The app is split into a Streamlit frontend and a FastAPI backend, with language detection and translation built in for multilingual use.
[!CAUTION] ## โ ๏ธ Medical Disclaimer โ READ BEFORE USE CoughGPT is a student/learning project built purely for educational and demonstration purposes. - The disease predictions and drug recommendations generated by this application are NOT medically verified, NOT clinically validated, and must NOT be used for self-diagnosis or self-medication. - The AI model outputs are based on limited training data and can produce incorrect, incomplete, or misleading results. - Do NOT take any medication based on what this app suggests. Always consult a qualified medical professional for health concerns, diagnosis, and treatment. - The creators of CoughGPT are not medical professionals and accept no responsibility or liability for any actions taken based on the outputs of this application. - If you are experiencing a medical emergency, call your local emergency services immediately. Use this project only to explore how ML pipelines and LLM integrations work โ not as a health tool.
๐ง Overview
CoughGPT is designed as a fast, modular health assistant with three core capabilities:
- Disease prediction from comma-separated symptom input.
- Drug recommendation based on the predicted condition.
- AI-generated explanation of the result using Google Gemini.
The system also detects the user's language, translates non-English input to English for analysis, and translates the final response back to the original language when needed.
โจ Key Features
- FastAPI backend with startup model loading through a lifespan context manager.
- X-API-Key authentication for protected endpoints.
- Language detection using
langdetect. - Translation using
deep-translator. - Disease prediction with FastText embeddings and a trained classifier.
- Drug recommendation from the drug review dataset.
- Medical explanation generation using Google Gemini 2.5 Flash.
- Streamlit frontend with a clean, responsive UI.
๐ ๏ธ Tech Stack
โ๏ธ How It Works
The backend performs the full pipeline in a single /api/analyze call:
- Detect the input language.
- Translate to English if necessary.
- Decide whether the input is a symptom list or a condition name.
- Predict the disease for symptom input, then derive recommended drugs.
- Call Gemini for a short medical explanation.
- Translate the explanation back to the user's language when required.
๐ Deployment Architecture
This specific branch (hf-deployment) is optimized for deployment on Hugging Face Spaces using a custom Docker container.
- Dual-Service: Uses
supervisordto run both the FastAPI backend and Streamlit frontend in a single container. - Dynamic Model Loading: Heavy ML models (.pkl, .h5, etc.) are omitted from this repository to save space and are downloaded dynamically from a dedicated Hugging Face Model repository at runtime using
huggingface_hub. - Environment Variables: Secrets (like
GEMINI_API_KEYandAPI_SECRET_KEY) are injected securely at runtime via Hugging Face Space Settings.
๐ก API Endpoints
๐ Notes
- The backend loads ML models once at startup to avoid reloading large artifacts on every request.
- The frontend is UI-only and talks to the backend over HTTP internally within the Docker container.
- This project is intended for educational and informational use only and is not a substitute for professional medical advice.
๐ License
This project is licensed under the MIT License.
