AI Health Counselor
π₯ AI Health Counselor β RAG-Powered Medical Guidance
Responsible AI for health counseling β a retrieval-augmented generation (RAG) system providing structured, safety-first medical guidance over curated datasets with context-aware dialogue.
π Overview
Healthcare AI requires more than just high accuracy; it requires rigorous safety guardrails, context-aware memory, and the ability to strictly adhere to topic boundaries. This project implements a RAG-powered Health Counselor designed to provide informative, responsible medical guidance while minimizing hallucinations and ensuring mandatory disclaimers are always present.
The system utilizes ChromaDB for efficient retrieval over thousands of curated medical Q&A entries and Pydantic for strictly structured outputs to ensure consistency in medical advice formatting.
βοΈ Project Details
| Property | Value |
|---|---|
| Domain | Healthcare / Medical Q&A |
| Data Source | Curated Medical Q&A Datasets |
| Retrieval Engine | ChromaDB (Vector Search) |
| Memory Strategy | Sliding-Window Conversation Memory |
| Routing | Function Calling for Symptom Follow-up |
| Safety | Hallucination Detection & Topic Filtering |
π‘οΈ Safety & Responsibility Layer
- Topic Boundary Filtering: Automatically rejects queries outside the medical/health domain to prevent misuse.
- Hallucination Detection: Cross-references generated responses against retrieved context to flag potential factual errors.
- Mandatory Disclaimers: Automatically appends medical disclaimers to every response, emphasizing that the AI is not a substitute for professional medical advice.
π§ Approach
Dialogue & Reasoning Pipeline
User Query
β
βΌ
Safety Filter (Input Guardrails)
β
βΌ
Retrieval Step (ChromaDB)
β
ββββΊ Search curated medical Q&A
β
βΌ
Context-Aware Dialogue Engine (LangChain)
β
ββββΊ Sliding-window Memory (History)
ββββΊ Function Calling (Symptom Routing)
β
βΌ
Hallucination Detection (Verification)
β
βΌ
Structured Response (Pydantic + Disclaimer)
Key Techniques
- Context-Aware Multi-turn Dialogue: Implemented stateful conversation management using sliding-window memory, significantly improving response coherence across long user sessions.
- Symptom Follow-up Routing: Leveraged LLM function calling to identify when a user mentions specific symptoms, triggering prioritized routing to specialized follow-up diagnostic questions.
- RAG over Curated Data: Eschewed broad web-searches for retrieval over high-quality, verified medical Q&A pairs to ensure grounding in expert knowledge.
- Structured Output (Pydantic): Every response follows a rigid schema:
advice,supporting_evidence,suggested_next_steps, anddisclaimer.
π Repository Structure
health-counselor-ai/
βββ data/
β βββ curated_qa/ # Verified medical datasets
β βββ vectordb/ # ChromaDB index persistence
βββ src/
β βββ engine/ # Core LangChain RAG logic
β β βββ chains.py # Dialogue and retrieval chains
β β βββ memory.py # Sliding-window implementation
β βββ safety/ # Guardrails and filters
β β βββ hallucination.py # Fact-checking against context
β β βββ topic_filter.py # Domain boundary enforcement
β βββ routing/ # Function calling for symptom routing
β βββ schemas/ # Pydantic models for responses
βββ notebooks/
β βββ EDA_and_Indexing.ipynb # Data processing and embedding
βββ requirements.txt
βββ README.md
π Performance & Coherence
- Response Coherence: High stability maintained across 10+ turn conversations due to the sliding-window memory strategy.
- Safety Compliance: 100% adherence to topic filtering for non-medical queries during testing.
- Retrieval Precision: High overlap between generated advice and retrieved reference documents.
The system was built with a βSafety Firstβ philosophy, prioritizing response grounding and disclaimer inclusion over conversational creativity.
π οΈ Tech Stack
| Component | Tool |
|---|---|
| Orchestration | LangChain |
| Vector Store | ChromaDB |
| Validation | Pydantic |
| Logic | Python |
| LLMs | OpenAI GPT-4o / Claude 3 Sonnet |
| Metrics | RAGAS (for retrieval/generation evaluation) |
π References
- LangChain Documentation β Memory
- ChromaDB: The AI-Native Open Source Embedding Database
- Guardrails AI β Input/Output Validation
- Pydantic Official Site
Focusing on responsible, grounded AI solutions for healthcare guidance.
