A Simple web interface for the Medical Agentic RAG (Retrieval-Augmented Generation) system built with Flask, featuring an intelligent routing system that dynamically selects the best data source for medical queries.
- Intelligent Routing: Automatically determines whether to search Medical Q&A database, Medical Device Manuals, or perform Web Search
- Real-time Workflow Visualization: See the decision-making process in action
- Context Relevance Check: Ensures retrieved information is relevant to the query
- Beautiful Modern UI: Dark-themed, responsive design with smooth animations
- Example Queries: Quick-start with pre-populated medical questions
- Metadata Display: Shows route decision, information source, and relevance status
- Python 3.12+
- All dependencies from the original
agentic_RAG.pyproject - Flask web framework
- Install dependencies:
pip install -r requirements.txt-
Ensure your environment variables are set:
- OpenAI API key
- Google Serper API key (for web search)
-
Make sure ChromaDB collections are initialized:
- The app requires
collection1(Medical Q&A) andcollection2(Medical Device Manuals) fromchromaDB.py
- The app requires
- Start the Flask server:
python app.py- Open your browser and navigate to:
http://localhost:5000
- Start asking medical questions!
rag_agentic/
├── app.py # Flask backend server
├── agentic_RAG.py # Core agentic RAG logic
├── chromaDB.py # Vector database collections
├── results_openai.py # LLM integration
├── requirements.txt # Python dependencies
├── templates/
│ └── index.html # Main web interface
└── static/
├── style.css # Beautiful styling
└── script.js # Interactive functionality
- User Input: Enter a medical query in the text area
- Router Decision: AI decides which data source to use:
Retrieve_QnA: General medical knowledge, symptoms, treatmentsRetrieve_Device: Medical devices, manuals, instructionsWeb_Search: Recent news, brand names, external data
- Context Retrieval: Fetches relevant information from the chosen source
- Relevance Check: Verifies if the retrieved context is relevant
- Response Generation: Creates an informed answer using the context
- Display Results: Shows the answer with full metadata and workflow visualization
- Dark Modern Theme: Easy on the eyes for medical professionals
- Responsive Design: Works on desktop, tablet, and mobile
- Smooth Animations: Elegant transitions and loading states
- Keyboard Shortcuts: Press Ctrl/Cmd + Enter to submit queries
- Example Queries: Quick-start buttons for common questions
- Workflow Visualization: See each step of the agentic process
Try these queries to see the system in action:
- "What are the treatments for Kawasaki disease?"
- "What are the usage of Dialysis Machine Device?"
- "What are medicines/treatment for COVID?"
- "What's the export duty on medical tablets on India by USA in 2025?"
The agentic workflow is defined in agentic_RAG.py. You can customize:
- Routing logic in the
router()function - Relevance checking criteria in
check_context_relevance() - Number of results retrieved (
n_resultsparameter) - Response length limit in the prompt
Edit static/style.css to customize:
- Color scheme (CSS variables in
:root) - Layout and spacing
- Animations and transitions
- Responsive breakpoints
If port 5000 is already in use, change it in app.py:
app.run(debug=True, host='0.0.0.0', port=8080)Ensure your ChromaDB collections are properly initialized:
python chromaDB.pySet your environment variables:
export OPENAI_API_KEY="your-key-here"
export SERPER_API_KEY="your-key-here"- Always use environment variables for API keys (never hardcode)
- Consider adding rate limiting for production use
- Implement user authentication if deploying publicly
- Use HTTPS in production environments
- Built with LangGraph for workflow orchestration
- Powered by OpenAI for language understanding
- ChromaDB for efficient vector storage
- Google Serper for web search capabilities