An intelligent medical chatbot powered by Retrieval-Augmented Generation (RAG) that helps healthcare professionals and patients get accurate answers from uploaded medical documents.
- 📄 PDF Document Upload: Upload multiple medical PDFs to build your knowledge base
- 🤖 AI-Powered Chat: Ask questions and get contextual answers from your documents
- 🔍 Source Attribution: See which documents your answers come from
- 💾 Chat History: Download your conversation history for record keeping
- ⚡ Real-time Processing: Fast document indexing and query responses
- 🌐 Web Interface: Clean, intuitive Streamlit frontend
This project uses a modern microservices architecture:
- Frontend: Streamlit web application (
client/) - Backend: FastAPI REST API (
server/) - Vector Database: Pinecone for document embeddings
- LLM: Google Generative AI (Gemini)
- Embeddings: Google Generative AI Embeddings
- Python 3.13+
- UV package manager
- Pinecone API key
- Google AI API key
-
Clone the repository
git clone <your-repo-url> cd RAGMedicalAIAssistant
-
Set up virtual environment
uv venv .venv\Scripts\activate # Windows # or source .venv/bin/activate # macOS/Linux
-
Install dependencies
uv pip install -r requirements.txt
-
Environment setup Create a
.envfile in the root directory:PINECONE_API_KEY=your_pinecone_api_key PINECONE_INDEX_NAME=your_index_name GOOGLE_API_KEY=your_google_ai_api_key
-
Start the FastAPI backend
uvicorn main:app --reload
Backend will be available at
http://localhost:8000 -
Start the Streamlit frontend
cd client streamlit run app.pyFrontend will be available at
http://localhost:8501
- Upload Documents: Use the sidebar to upload medical PDF documents
- Wait for Processing: Documents are automatically processed and indexed
- Ask Questions: Type your medical questions in the chat interface
- Get Answers: Receive AI-generated responses based on your documents
- Download History: Save your chat history for future reference
RAGMedicalAIAssistant/
├── client/ # Streamlit frontend
│ ├── components/ # UI components
│ │ ├── chatUI.py # Chat interface
│ │ ├── upload.py # File upload component
│ │ └── history_download.py
│ ├── utils/ # Client utilities
│ │ └── api.py # API client functions
│ ├── config.py # Client configuration
│ └── app.py # Main Streamlit app
├── server/ # FastAPI backend
│ ├── routes/ # API endpoints
│ ├── modules/ # Core business logic
│ ├── middlewares/ # Custom middleware
│ └── logger.py # Logging configuration
├── main.py # FastAPI application entry point
├── requirements.txt # Python dependencies
└── README.MD # This file
POST /upload_pdfs/- Upload and process PDF documentsPOST /ask- Submit questions and get AI responses
- Frontend: Streamlit, Python
- Backend: FastAPI, Uvicorn
- AI/ML: LangChain, Google Generative AI
- Vector Database: Pinecone
- Document Processing: PyPDF
- Environment: UV, Python-dotenv
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
This tool is for educational and informational purposes only. Always consult with qualified healthcare professionals for medical advice and decisions.
If you encounter any issues or have questions, please open an issue on GitHub.
Built with ❤️ for the healthcare community